Here's my question. I wrote this query:Bob,
Select * FROM name WHERE last LIKE "d" AND choice1="2" OR choice2="2" OR
choice3="2";
What I'm looking for are records that satisfy the LIKE "d" condition
But then, Only one of the three other conditions need be true:
choice1=2
choice2=2
choice3=2
I want to cover the possibilities, e.g.,
choice1=2 choice2=1 choice3=1
choice1=1 choice2=2 choice3=whatever
Or choice1=1 choice2=1 choice3=2
Does this make sense? The query I've written doesn't seem quite right. Because of the AND following the LIKE "d" condition, it seems like all the records will have to have choice2 equaling 2.
Some help clarifying this issue would be appreciated. Thanks.
Bob Cohen b.p.e.Creative http://www.bpecreative.com Design and production services for the web Put creative minds to work for you
You should have used some paranthese to separate the clauses u want for or. You may be getting errors because of the operator precedence. 'And' is having higher precedence than 'or'. Further like should be used with wildcard chars '%' or '_' .I fu re-write ur qry like
Select * FROM name WHERE last LIKE "%d%"
AND (choice1="2" OR choice2="2" OR choice3="2"); //This gives all recs where last is having char "d" anywhere in the string.
// 'd%' -> starting with 'd'
// '%d' -> ending with 'd'
ur next reqrmnet.
If u want to cover all possibilities in singlr querry u should use 'IN' operator like
(choice1 IN ("2","1") or choice2 IN ("1","2")).
Else u may have to use separate qrys.
reg,
Eldo Skaria.
--
#-----------------------------------------------# # Viva OpenSource # #-----------------------------------------------#
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]