Jump to content

Simple SQL question


Omabala

Recommended Posts

Could someone please tell me how to retrieve a table so that one column simply displays something and another column counts something

for example:

SELECT COUNT(u_id), SELECT countryName
FROM _AEsurvey_rego
WHERE countryName LIKE ('China')
GROUP BY countryName;

but I get this error message:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT countryName  FROM _AEsurvey_rego  WHERE countryName LIKE ( 'China' )  GRO' at line 1

Cheers.
Link to comment
https://forums.phpfreaks.com/topic/23488-simple-sql-question/
Share on other sites

SELECT countryName, COUNT(u_id)
FROM _AEsurvey_rego
WHERE countryName LIKE 'China'
GROUP BY countryName;

This ought to work.. I'm a bit confused as your query and error message do not match up.

Or maybe they do match up, and mysql removes the second select.  In any case, you only need to say "select" once :)
Link to comment
https://forums.phpfreaks.com/topic/23488-simple-sql-question/#findComment-106667
Share on other sites

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.