![]() |
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 |
you probably mean...
Code:
SELECT ... FROM tbl WHERE field_name IN('value1', 'value 2'[, ...]) |
I really need to study up on my SQL statements...
|
Exactly what the doctor ordered!
Thank you, Dave |
And you should remember to use two eaqual "==" when comparing variables.... or else it will asign.
i fall for that one myself time to times. Oh sorry. Didnīt see that it was in the SQL. Then itīs fine i guess. |
A good thing to ALWAYS be aware of, though. It has tripped me up more than once, and, unfortunately, I'm sure it will in the future. I need a wall poster of [...can't make up my mind...Pam Anderson?..Sarah Palin..?..Satan?...] with the "==" rule plastered underneath!
Thanks, Dave |
Quote:
|
No, Bill Clinton's photo would appear over the "is-is" rule, not the "==" rule.:-)
|
| All times are GMT. The time now is 04:07 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0