I need to make query that will select all names and all nicknames from some table but only where id is in some array.This is The query:
SELECT n. * FROM nikovi n
INNER JOIN sajt_nikovi s ON n.id = s.nik
WHERE s.sajt = '50' and n.nadimak like '%ana%' or n.ime like '%ana%'
And it found all entries from table where n.ime like ‘%ana%’, not only those for this join. does anyone have any idea?
AND binds harder than OR, which means that that it will evaluate something like;
If you mean something else, you need to add parenthesis to make it clear to the database. In this case, you will need to change it to;