How should this SQL statement be written? , and have been doing it for a long time.
Table A is present with the following fields:
ID ident_name icon ImageIcon
01 Yellow icon/a.jpg Icon/a1.jpg
02 Liu Icon/b.jpg Icon/b1.jpg
03 Zhang Icon/c.jpg Icon/c1.jpg
04 Li Icon/d.jpg icon/d1.jpg
Table B exists with the following fields:
ID friend Myfriend
01 Huang Liu
02 Huang Zhang
Ident_name and friend, I want to check the table B yellow Friends related information: SQL statement How?//////as follows
Friend Myfriend icon ImageIcon
Huang Liu Icon/a.jpg icon/a1.jpg
Huang Zhang Icon/b.jpg icon/b1.jpg
------Solution--------------------
Select B.friend, B.myfriend, A.icon, a.imageicon from table b b inner JOIN table A A on b.myfriend=a.ident_name
------Solution--------------------
SELECT * from A where ident_name in (select Myfriend from B where friend = ' yellow ')
------Solution--------------------
Select B.friend,b.myfriend, (select A.icon from Table A a where a.ident_name=b.myfriend) as icon, (select A.imageicon from Table A A where A.ident_name=b.myfriend) as ImageIcon from table b b where b.friend= ' yellow '
Stupid method ~ ~, do not know how efficient.