mysql with inner query -


i have table stores answer survey , im trying query mysql tell me if survey answered answer field = 16 or 20

i have following mysql statement

select distinct(submissionid) submissionid answer  exists (     select *     answer     submissionid = submissionid , (answer = '16' or answer = '20')  ) 

edit here

sorry dont think said question right here table structure:

create table if not exists `answer` (   `aid` int(11) not null auto_increment,   `sid` int(11) not null,   `qtid` int(11) not null,   `answer` text not null,   `userip` text not null,   `submissionid` int(11) not null,   primary key (`aid`) ) engine=myisam  default charset=latin1 auto_increment=422 ; 
  1. aid unique id every answer given
  2. sid survey id (cause may have more 1 survey)
  3. qtid questionsid value
  4. answer answer user gave qtid of survey
  5. userip self explainable
  6. submissionid id gave each submission

so know in table there 5 unique submissionid's there 1 submssionid answer field = 16 , 20

i think query overly complex, try this:

select distinct submissionid answer  answer in ('16', '20'); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -