跳转到主内容
趣航编程网 - 趣学编程,启航技术之路!

这样一句SQL语句应该如何写?搞了很久没有做出来

这样一句SQL语句应该怎么写?、、搞了很久没有做出来

存在表A,字段如下:

id     ident_name    icon        imageicon 01         黄       icon/a.jpg      icon/a1.jpg 02         刘       icon/b.jpg     icon/b1.jpg 03         张       icon/c.jpg     icon/c1.jpg 04         李       icon/d.jpg     icon/d1.jpg

存在表B,字段如下:

id   friend  myfriend 01    黄        刘02    黄         张ident_name和friend相关, 我想查询的表B黄的朋友相关资料:SQL语句怎么?//////如下friend  myfriend    icon        imageicon黄         刘       icon/a.jpg    icon/a1.jpg黄         张       icon/b.jpg    icon/b1.jpg------解决方案--------------------select b.friend  ,b.myfriend , a.icon, a.imageicon from 表B b inner join 表A a on b.myfriend=a.ident_name------解决方案--------------------select * from A where ident_name in (select myfriend from B where friend = '黄')------解决方案--------------------select b.friend,b.myfriend ,(select a.icon from 表A a where a.ident_name=b.myfriend) as icon, (select a.imageicon from 表A a where a.ident_name=b.myfriend) as imageicon  from 表B b where b.friend='黄'笨方法~~,不知道效率如何。

相关文章