Jump to content


Problem with query HELP!!!

  • Please log in to reply
2 replies to this topic

#1 Omabala

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 October 2006 - 12:20 AM

Im trying to retrieve information from 3 different tables and end up with a table with 5 columns:

1st column displays vis_type
2nd column displays countryName
3rd column displays the total number of u_id
4th column displays average score of aesth_rank
and 5th column displays average score of x_pos

MySQL keeps telling me something is wrong with my 2nd line...it seems to not like how i type SELECT COUNT (...)

Can any1 tell me all the errors in my query...I'm just a beginner

SELECT a.vis_type, c.countryName
AND SELECT AVG(‘a.aesth_rank’)
AND SELECT AVG(‘b.x_pos’)
FROM _AEsurvey_meta_info a, _AEsurvey_aesth_rank b, _AEsurvey_rego c
WHERE (a.vis_type = '1' AND c.countryName LIKE ('China'))
OR (a.vis_type=’2’ AND c.countryName LIKE (‘China’))
AND a.u_id = b.u_id
AND b.u_id = c.u_id
GROUP BY a.vis_type;


#2 btherl

  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 10 October 2006 - 07:25 AM

There's certainly something odd with the quotes.  In general, you don't need to put any quotes around column names.

SELECT a.vis_type,
           count(a.u_id) AS a_u_id_count,

This style should work.

#3 Vikas Jayna

Vikas Jayna
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts
  • LocationNoida, Delhi, India

Posted 10 October 2006 - 07:46 AM

Firstly, the word 'SELECT' is to be used only once and all the columns to be displayed have to be comma separated instead of 'AND' and then the column names are not to have quotes
Vikas Jayna,
Project Manager - Jeevansathi.com
7 yrs. exp. in LAMP
Certified Mysql DBA
Zend Certified Engineer

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users