I have a table like this:
id price condition username
----------------------------------------
1 20 New Kim
2 30 Used Kim
3 40 Used George
4 60 New Tom
My question is about the subquery. when i use this query
SELECT *
FROM `table`
WHERE `username` = 'kim'
AND `price` = '20'
OR `condition` = 'New'
this becomes true for the last condition and brings 2 entries, where condition = 'New'
However, when I use AND, it returns the correct entry.
SELECT *
FROM `table`
WHERE `username` = 'kim'
AND `price` = '20'
AND `condition` = 'New'
I want to enclose the request so that I can select the price and condition only from the results of the first request, which is the username. Thanks
karto source
share