In a tutorial I saw this SQL query:
SELECT a.id as a_id, a.info as a_info,
b.id as b_id, b.info as b_info
FROM stats AS a
JOIN stats as b
ON a.id != b.id
LIMIT 25
The query is working well, but now I would need to add the WHERE condition. I have the table users. The table stats contains the column user_id.
I try to obtain all users from the table stats if users.city=1 (for example), but I still cannot to find a way, how to achieve that…
My problem is, that I currently have no clue, how to put into the query another JOIN (for table users).
I would be grateful for every advice, thank you
Well, as you use the table
statstwo times in your query, you would actually need two joins for theuserstable as well. (for stats A and stats B)