I have a database, with 2 different tables.
database01 > “friends” and “accounts”
If a User registers and has a REF, there will be created a special row in “friends” table. Its shows the REF1 ID and REF2 ID. Both ID are unique and find on table “accounts”, there is also the IP Address for each ID.
I’m trying to create a mysql query, which catches the 2 ID’s found on database01.friends row REF1 and REF2, then based to their ID, catch the IP Address from database01.accounts row web_ip, then COMPARE it, and if its same, show them. Like a SELECT query.
I tried it this way, but I think its not correct at all:
SELECT id, REF1, REF2 from database01.friends WHERE "REF1" and "REF2" web_ip = web_ip (SELECT id, web_ip FROM `database01.accounts`)
SELECT F.ID, F.REF1, F.REF2 FROM FRIENDS F LEFT JOIN ACCOUNTS A1 on A1.id = F.REF1 LEFT JOIN ACCOUNTS A2 on A2.id = F.REF2 WHERE A1.WEB_IP = A2.WEB_IP;
Answered By – bekt
Answer Checked By – Marilyn (BugsFixing Volunteer)