Jump to content

Can't solve Advanced SQL Syntax


david212

Recommended Posts

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:

64n5f.png

 

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

Link to comment
https://forums.phpfreaks.com/topic/233251-cant-solve-advanced-sql-syntax/
Share on other sites

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:

64n5f.png

 

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'])	.".";
}

?>

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.

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.