Re: simplify query?
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]
simplify query?
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]
Re: simplify query?
Reto Baudenbacher [EMAIL PROTECTED] 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 What do you mean 'simplifiy'? You can rewrite the above query using UNION instead of OR, but the new query will not be very simple, too. -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]