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

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.