Jump to content

Archived

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

Omabala

Simple SQL question

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.

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

×

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.