What you want to do is "reduce" the query. Logic is reduced using similar rules to algebra.

Think of "or" operations as addition and "and" operations as multiplication and you can manipulate them using the same rules as you do in algebra.

select * from t where (a and b) or (a and c);

where a, b and c are conditions

this query could be restated as

select * from t where a and (b or c);

your query is of the form

(a or b or c) and (d or e or f),

which I don't think can be reduced any further, but it can certainly be made more complicated as in (a and d) or (a and e) or (a and f) or (b and d) ...

--
Michael Conlen

Reto Baudenbacher wrote:

hi

Sorry for this newbie-question:

is it possible to simplifiy the following (working) query?



"SELECT * FROM mytable WHERE

((col1 LIKE '%test%') OR (col2 LIKE '%test%') OR (col3 LIKE 'test%'))

AND

(col5 = 'y' OR col6 = 'y' OR col7 = 'y') ORDER BY col1"




Thanks for any suggestions! Reto Baudenbacher







-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to