david212 Posted April 10, 2011 Share Posted April 10, 2011 Hello guys, I'm trying to solve my hometask . I tried in many different ways to solve the task related with Advanced SQL Syntax. Please check the pic below: The Quiz is asking for make location appear in all uppercase letters, the character associated with a given ASCII value and the table is people. I tried the last one in this way: SELECT CONCAT(name,'is from',strtoupper(location),' The ASCII character of the number ',number,' is ',ASCII(number)) FROM `people` WHERE 1 but it doesn't work. Can someone help me? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/ Share on other sites More sharing options...
3raser Posted April 10, 2011 Share Posted April 10, 2011 Hello guys, I'm trying to solve my hometask . I tried in many different ways to solve the task related with Advanced SQL Syntax. Please check the pic below: The Quiz is asking for make location appear in all uppercase letters, the character associated with a given ASCII value and the table is people. I tried the last one in this way: SELECT CONCAT(name,'is from',strtoupper(location),' The ASCII character of the number ',number,' is ',ASCII(number)) FROM `people` WHERE 1 but it doesn't work. Can someone help me? Thanks I've never seen someone actually putting the code to output in an SQL query. Not sure if it would work, but hey, I don't know if you can do that or not. I've just never seen it before. Anyways: Mind trying this? <?php $query = mysql_query("SELECT `name`,`location`,`number` FROM `people` WHERE 1"); while($grab = mysql_fetch_assoc($query)) { echo $grab['name']. " is from ". strtoupper($grab['location']) .". The ASCII character of the number ". $grab['number'] ." is ". ASCII($grab['number']) ."."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199585 Share on other sites More sharing options...
david212 Posted April 10, 2011 Author Share Posted April 10, 2011 Thanks for the reply Justin but me too Im a bit confused. This is a sql syntax i have to solve as a hometask. I submitted solution for php but it was not accepted. Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199588 Share on other sites More sharing options...
3raser Posted April 10, 2011 Share Posted April 10, 2011 Thanks for the reply Justin but me too Im a bit confused. This is a sql syntax i have to solve as a hometask. I submitted solution for php but it was not accepted. Are you saying you are REQUIRED to fix the syntax? I'm not saying their isn't, because I'm not exactly sure, but I don't think you can do a MySQL query that way. I'd recommend you use a way like mine or similar. Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199590 Share on other sites More sharing options...
david212 Posted April 10, 2011 Author Share Posted April 10, 2011 Yes , I'm REQUIRED Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199597 Share on other sites More sharing options...
ignace Posted April 10, 2011 Share Posted April 10, 2011 SELECT concat(Name,' is from ',upper(Location),'. The ASCII character of the number ',Number,' is ',ascii(Number)) FROM people Your teacher can also browse the web, just so you know Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199608 Share on other sites More sharing options...
david212 Posted April 10, 2011 Author Share Posted April 10, 2011 I know but I changed string names It doesn't matter at all. I would like to find an answer for this quiz. Three times I showed him my work and all of them were rejected so that's why I had to post to find a help Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199611 Share on other sites More sharing options...
sadavied Posted April 10, 2011 Share Posted April 10, 2011 Here's how I solved it: select concat(Name,' is from ',upper(Location),'. The ASCII character of the number ',Number,' is ',ascii(Number),'.') as Result from people; Output: +-------------------------------------------------------------------+ | Result | +-------------------------------------------------------------------+ | Bond is from LONDON. The ASCII character of the number 50 is 53. | | Tom is from IRELAND. The ASCII character of the number 100 is 49. | +-------------------------------------------------------------------+ 2 rows in set (0.00 sec) Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199670 Share on other sites More sharing options...
david212 Posted April 11, 2011 Author Share Posted April 11, 2011 Thanks a lot!!! Quote Link to comment https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/#findComment-1199923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.