Jump to content

[SOLVED] Problem with simple mysql select query


robs99

Recommended Posts

Hello,

i have a problem with a mysql query. this is my query:

 

SELECT * FROM `posts`
WHERE `bandname` LIKE '%something%' OR `title` LIKE '%something%'
AND `deleted` = ''
AND `approved_by` != ''
ORDER BY `date` DESC , `id` DESC LIMIT 0 , 30

 

im trying to perform a search (my search parameter is 'something'). the results show up properly, but it ignores the rest of the query. deleted and unapproved posts still show up for some reason...any ideas?

 

thanks in advance

In which case it's to do with the order of precedence of the operators you're using.

Try:

SELECT * FROM `posts`
WHERE (`bandname` LIKE '%something%' OR `title` LIKE '%something%')
AND `deleted` = ''
AND `approved_by` != ''
ORDER BY `date` DESC , `id` DESC LIMIT 0 , 30

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.