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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.