Reputation: 175
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"
Upvotes: 0
Views: 239
Reputation: 46965
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'
Upvotes: 2
Reputation: 9389
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'
Upvotes: 2