Jump to content

Recommended Posts

My goal in this query is to search for books and return ones with certain ids and words in a column. For example, I have a table of books with title and itemid columns. And i have 4 itemid values: 5, 67, 46, 12. I also want to only return the values of those books whose title contain "exploring". So if the table was this:

 

5 exploring world
67 hello world
46 exploring life
12 exploring earth
345 this is random
23 exploring this
1 bar

 

I should return rows 1, 3, and 4. What can I do to get this? I tried:

 

SELECT * FROM thetable WHERE itemid = 5 OR itemid = 67 OR itemid = 46 OR itemid =12 OR title LIKE '%exploring%'

 

But that would bring up rows 1, 2, 3, 4, and 6. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/157616-solved-complicated-query/
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.