I got players table and host field in it, I also got a second table called bans with the following fields: host, second_host, ip. I need to check if players.host content field is not equal to any of those three fields in the bans table, with one condition: WHERE expiry >= UNIX_TIMESTAMP().
I’ve already built this one, but as you can see, there are three conditions in the bans table, and now I don’t know what to do.
SELECT * FROM players
WHERE host NOT IN (
SELECT host
FROM bans
WHERE expires >= UNIX_TIMESTAMP()
)
Now I’d have to do the same for three other fields (second_host and ip). Is that will be possible to do in one query? If so, please post an example.
It’s easiest to do this in a join condition:
Learn about SQL joins.