tags:

views:

70

answers:

2

I need to do a select that select only the abv = "yes" and other filters,like:

SELECT *
FROM `business`
WHERE `category` LIKE ('$_GET[search]%')
OR `location` LIKE ('$_GET[search]%')
OR `name` LIKE ('$_GET[search]%')
OR `address` LIKE ('$_GET[search]%')
AND `apv`='yes'

This is not working, if I put it all AND does not return anything, on the other hand if I put OR returns including the apv is different from "yes"

I need to select it:

SELECT *
FROM `business`
WHERE `category` LIKE ('$_GET[search]%')
OR `location` LIKE ('$_GET[search]%')
OR `name` LIKE ('$_GET[search]%')
OR `address` LIKE ('$_GET[search]%')

But only with apv="yes"

+2  A: 

Try

    SELECT *
FROM `business`
WHERE (
 `category` LIKE ('$_GET[search]%')
 OR `location` LIKE ('$_GET[search]%')
 OR `name` LIKE ('$_GET[search]%')
 OR `address` LIKE ('$_GET[search]%')
)
AND `apv`='yes'
Gratzy
+2  A: 

Did you try putting parens around the or clauses?

SELECT *
    FROM `business`
    WHERE (
    `category` LIKE ('$_GET[search]%')
    OR `location` LIKE ('$_GET[search]%')
    OR `name` LIKE ('$_GET[search]%')
    OR `address` LIKE ('$_GET[search]%')
    )
    AND `apv`='yes'
ennuikiller