Php MySQL在一个表中查找包含另一个表信息的行
目前,我有两个MySQL表 第一个表存储朋友和他的照片之间的关系 表1Php MySQL在一个表中查找包含另一个表信息的行,php,mysql,Php,Mysql,目前,我有两个MySQL表 第一个表存储朋友和他的照片之间的关系 表1 id | pic_id | friend_id ---------------------------- 0 | 123 | 84589 1 | 290 | 11390 2 | 884 | 84589 表2 第二个表存储有关pic的更多信息 id | pic_id | title | color | detail -------------
id | pic_id | friend_id
----------------------------
0 | 123 | 84589
1 | 290 | 11390
2 | 884 | 84589
表2
第二个表存储有关pic的更多信息
id | pic_id | title | color | detail
----------------------------------------------
0 | 123 | hello | black | brush
1 | 124 | world | red | paint
2 | 884 | sample | green | star
我有我的朋友id,需要从表1中获取所有pic_id,然后使用pic_id从表2中获取列(标题、颜色、细节)
在MySQL中我将如何做到这一点
谢谢大家! 只需将两个表连接起来
SELECT b.title, b.color, b.detail
FROM table1 a INNER JOIN table2 b
on a.pic_id = b.pic_id
WHERE friend_id = 84589