radalin Posted November 8, 2007 Share Posted November 8, 2007 Hi, I'm curious if it's possible to learn which where clause has returned true on the current query. Something like: SELECT * FROM table1 WHERE col1 = 'sometext' OR col2 = 1 OR col3 IN ('some','number','here'); I want to know which where clause has returned true in this query. The col1 or col2 or col3. It can be done by querying all where clauses one by one but i do not prefer it. Well I hope I was able to explain myself. Thank you for your time. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 8, 2007 Share Posted November 8, 2007 The only "easy hack" is to add expressions to your column list to would evaluate to true/false: SELECT *, IF( col1 = 'sometext', 1, 0 ) AS clause1, IF( col2 = 2', 1, 0 ) AS clause2, IF( col3 = 'some' OR col3 = 'number' OR col3 = 'here' ) etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.