Am having a MYSQL db and i want to select accounts thats connected in table users and table friends
this is my query
SELECT id(distinct FRIENDS.ID) FROM FRIENDS JOIN USERS ON FRIENDS.ACC IN (FRIENDS.ACC, FRIENDS.CONTO)
WHERE #USER FT11 IN (FRIENDS.ACC, FRIENDS.CONTO)
This is the error i get
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
TABLE USERS
ID USER_ACC NAME
1 FT11 JANE
2 FT22 FRED
3 FT33 KEN
TABLE FRIENDS
ID ACC CONTO
1 FT11 FT33
ACC can be my account or CONTO can be my account
so i want to select or check these accounts am connected with on same column in FRIENDS table
2
Answers
Probably this is what you want.
I have added a code snippet:
SELECT DISTINCT F.ID FROM FRIENDS F JOIN USERS U ON F.ACC = U.USER_ACC OR F.CONTO = U.USER_ACC
WHERE U.USER_ACC = ‘FT11’;
Try using this.