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 ; aidunique id every answer givensidsurvey id (cause may have more 1 survey)qtidquestionsid valueansweranswer user gaveqtidof surveyuseripself explainablesubmissionidid 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
Post a Comment