Jump to content

Using OR and AND together


mapleleaf

Recommended Posts

I am trying to get this to work:

SELECT * FROM articles WHERE (SELECT * FROM articles WHERE theme_id = 10 OR FIND_IN_SET(9, second_theme)) AND name = 'john' AND deleted = 'No'

 

My error is:

Operand should contain 1 column(s)

 

What is the way around this?

This query is dynamic in that multiple ANDS are sometimes added.

Link to comment
https://forums.phpfreaks.com/topic/193576-using-or-and-and-together/
Share on other sites

Getting an odd error with this.

SELECT * FROM articles WHERE FIND_IN_SET(32, second_theme) AND deleted = 'No'
//gives 16 rows

SELECT * FROM articles WHERE theme_id = 34 AND deleted = 'No'
//gives 13 rows

SELECT * FROM articles WHERE theme_id = 34 OR find_in_set(32, second_theme) AND deleted = 'No'
//gives 32 rows because 3 of the rows have 'Yes' for deleted.
SELECT * FROM articles WHERE theme_id = 34 AND find_in_set(32, second_theme) IS NOT NULL AND deleted = 'No' 
//gives 13 rows so basically excludes all the second_theme

 

I want to to be able to do the OR and then the AND conditions should be applied the results of the OR.

Tx

 

 

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.