View Single Post
Old 09-13-2008, 02:18 PM   #1 (permalink)
Dave
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default SELECT statement -- list of fields in WHERE clause

Hi --

Can the list of fields in the WHERE clause of the following SELECT statement be written more efficiently? I used to use a program with an INLIST() option in which several fields could just be listed: WHERE INLIST(fieldname,"value1","value2",etc.) Can't find anything in MySQL, but then I don't have much experience...Thanks for any help!

Dave

Code:
select distinct coursetitle, statecourse, localcourse, semester, section, teachername
   from mytable
   where (semester = "0" or semester = "1") 
         and coursetitle is not null 
         and (statecourse = "1021X" or
              statecourse = "2020X" or
              statecourse = "2023X" or
              statecourse = "2024X" or
              statecourse = "2030X" or
              statecourse = "3010X" or
              statecourse = "3020X" or
              statecourse = "3038X" or
              statecourse = "3050X" or
              statecourse = "3060X" or
              statecourse = "4021X" or
              statecourse = "4024X" or
              statecourse = "4052X"
             )
   order by statecourse;
Dave is offline  
Reply With Quote