1
我有这个数据库:如何在内部连接上进行连接?
table
id fname dphone count_pic dup_id
6055903 Karla 5126xxx798 1 57
6173767 Aaliyah 4082xxx534 4 39
5611411 Aaliyah 4082xxx534 15 39
5611211 Aaliyah 4082xxx534 18 39
4234798 Abby 3057xxx974 31 16
6166691 Walter 6178xxx280 1 74
3375576 Walter 6178xxx280 17 74
,我发现怎么做就可以了内部联接是这样的:
SELECT *
FROM table t1
INNER JOIN (SELECT MIN(count_pic) AS minpic,
MAX(count_pic) AS maxpic,
dup_id
FROM table
GROUP BY dup_id) t2 ON t1.dup_id = t2.dup_id
AND (t1.count_pic = minpic
OR t1.count_pic = maxpic)
,但如果我想加盟此表是什么与另一个基于id
并返回一些值,如第二个表中的date,
以及:
table2
id date
6055903 111111111
6173767 111111111
5611411 111111111
对此的任何想法?
编辑:
内连接是好的事情是这样的,我需要对查询
刚添加第二个连接? 'SELECT * FROM table1 JOIN table2 ON(table1.id = table2.foreign_id)JOIN table3 ON(table1.id = table3.foreign_id)' – Thorsten