Jump to content

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

 

 

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.