Jump to content

[SOLVED] Complicated Query


lordzardeck

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

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.