It used to be that I used SQL for basic stuff and did the rest in my code. Now I'm starting to learn some of the cooler features of SQL and I'm trying to figure out what I can move into a query and what I'll still need my code to do thing. In trying this conversion, I've run across something and I'm wondering if this is legal in SQL/MySQL. This query is obviously wrong but is there a way I can do the same thing?
SELECT * FROM certificate WHERE active = 1 AND bound = 1 AND void = 0 AND premium_due <> 0 CASE WHEN '' != '' THEN AND payment_ref_num LIKE '%001%' AND payment_ref_num != '' WHEN '' != '' THEN AND uid = 'adt001' WHEN '' != '10747' THEN AND cert_num LIKE '%10747%' END; NB: for the "WHEN '' != ''" part of the query, once side (or the other) of the operand would have data, supplied by my code, in the quotes. If the variables aren't set, the value won't be part of the operation and as such, that particular CASE would resolve. Thanks for any help anyone can provide. I'm just trying to broaden my horizons. :p thnx, Chris -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]