I have two tables in my database. One of which is a table called players
and the other one is bans
:
players table: ID, Score bans table: user_id, reason
What I need to do is: select players that where reason = cheating and Score < 250.
I tried doing some JOINS when I tried FULL JOIN I found that thing doesn’t exist in MySQL so any help would be good, thanks in advance!
I also tried it like this but I always get zero rows
SELECT bans.user_id, players.ID FROM bans INNER JOIN players ON bans.user_id=players.ID;
BANS TABLE
user_id reason 133032 swearing 133040 name not allowed
PLAYERS TABLE
id score 15 13378 21 215216 133032 15 133040 157
Advertisement
Answer
You query is a good start. For your sample data, it will give you results. To meet your requirement, you just need a few additional filters:
select b.user_id, p.id from bans b inner join players p on p.id = b.user_id and p.score < 250 where b.reason = 'cheating'