Swathi Swathi - 4 months ago 16
SQL Question

Usage of (Where IN) clause of SQL

I am trying to search and display the following questions mentioned below in the code as excel output.
As my excel spreadsheet has LABEL and DATA as the two columns, the questions comes under the Column named LABEL, while its relevant YES/NO answers comes under column named DATA.

The first three questions should be displayed in the excel sheet, only if its answer is 'NO' !

WHERE Label IN ('Is the price adequate? ' AND Data='No',
'Were the proper measures taken prior? ' AND Data='No',
'Is the incident reported? ' AND Data='No',
'Did the both prices match?' ,
'Learning Methods',
'Next actions Required','Final feedback')


The above code when executed throws up all the questions in the output no matter if it is Yes/No

Answer

It looks like you need something like

WHERE 
    (
        Label IN ('Is the price adequate? ', 
                'Were the proper measures taken prior?   ', 
                'Is the incident reported?  '
             ) 
        AND Data='No'
    )
    or 
    (
        Label IN ('Did the both prices match?' ,
                  'Learning Methods',
                  'Next actions Required',
                  'Final feedback'
                  )
    )