我有两张table:
t1级
"IdT1;i1T1,n2T1
1;123;n2T1
2;234;n3T1
3;345;n4T1
4;678;n1T1
5;123;n2T1
6;234;n3T1
t2级
"idT2;n1T2;n2T2;i1T2
1;1n1T2;2n1T2;123
2;1n2T2;2n1T2;234
3;1n3T2;2n1T2;345
4;1n4T2;2n1T2;456
5;1n5T2;2n1T2;567
6;1n6T2;2n1T2;678
在sqlite3中
$req = $db -> prepare("SELECT T2.n1T2, T2.n2T2,
//COUNT(*)
FROM T1
INNER JOIN T2 ON T1.idT2 = T2.idT2
");
if ($res = $req->execute()) {
$arr = $res->fetchArray();
var_dump($arr);
}
我搜索n1t2和n2t2名称,即i1t1和i1t2之间相同值的计数
example:
1n1T2;2n1T2;2
1n2T2;2n2T2;2
1n3T2;2n1T2;1
...
i var\u dump for display,in wait best方法
1条答案
按热度按时间a11xaf1n1#
看起来您需要一个联接和聚合: