Jump to content

Multiple OR Statement Question


NoSalt

Recommended Posts

Hello All

 

    I have a MySQL question about multiple OR statements; I guess it could also be about multiple AND statements. Say I have the following statement:

 

SELECT * FROM EVENT_TABLE where EVENT_TYPE_ID = 1 OR EVENT_TYPE_ID = 2 OR EVENT_TYPE_ID = 3 OR EVENT_TYPE_ID = 6 OR EVENT_TYPE_ID = 10 OR EVENT_TYPE_ID = 11 OR EVENT_TYPE_ID = 13 OR EVENT_TYPE_ID = 15 OR EVENT_TYPE_ID = 16 OR EVENT_TYPE_ID = 34;

 

I was hoping that there was a shorter, more efficient way to do this. Maybe like this:

 

SELECT * FROM EVENT_TABLE where EVENT_TYPE_ID = {1 OR 2 OR 3 OR 6 OR 10 OR 11 OR 13 OR 15 OR 16 OR 34};

 

So far, however, I have had no luck stumbling on the key. Is there a way to do what I want or am I stuck with the "hammer approach"?

 

Thanks for reading and have a good day.  :)

Link to comment
https://forums.phpfreaks.com/topic/193263-multiple-or-statement-question/
Share on other sites

You are correct ... I came here to post that my initial finding didn't work after all. Yours works absolutely perfectly. Thank you very much for recognizing my incorrectness and rectifying the situation. Next time I'll know not to be so hasty with my "conclusions".

 

Have a great day.  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.