所以我想计算并回显来自table2
的行数,这些行与id
具有相同的row
table1
。
我理解函数mysqli_num_rows
功能,但是如何让rows
来自table2
的匹配id
?
总新手,还在搜索。认为这可能有助于我朝着正确的方向前进。谢谢你的帮助!
答案 0 :(得分:1)
mysqli_num_rows返回结果中的行数。 您应该编写另一个查询来返回表2中具有相同ID
的行数SELECT COUNT(*)
FROM table2
WHERE table2.id = <id>
答案 1 :(得分:1)
CREATE TABLE table1 (id INT);
CREATE TABLE table2 (id INT);
INSERT INTO table1 VALUES (1), (2), (3), (4);
INSERT INTO table2 VALUES (2), (4);
SELECT COUNT(*)
FROM table1
JOIN table2
ON table1.id = table2.id;
答案 2 :(得分:0)
试试这个:
SELECT `table2`.`id`, COUNT(`table2`.`id`) AS `num_rows`
FROM `table2`
LEFT JOIN `table1` ON `table2`.`id` = `table1`.`id`
WHERE `table2`.`id` IS NOT NULL
GROUP BY `table2`.`id`
ORDER BY `table2`.`id` ASC
答案 3 :(得分:0)
仅计算
select table2.id, count(*)
from table1, table2
where table1.id = table2.id
group by table2.id
知道什么是id和多少
//shader1
<script id="vshader1" type="x-shader/x-vertex">
#extension GL_EXT_draw_buffers : require
varying vec2 vUv;
void main(void){
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
</script>
<script id="fshader1" type="x-shader/x-fragment">
uniform sampler2D texture;
varying vec2 vUv;
void main(void) {
vec4 smpColor = texture2D(texture, vUv);
gl_FragData[0] = smpColor;
gl_FragData[1] = smpColor;
}
</script>
//shader2
<script id="vshader2" type="x-shader/x-vertex">
varying vec2 vUv;
void main(void){
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
</script>
<script id="fshader2" type="x-shader/x-fragment">
uniform sampler2D texture;
varying vec2 vUv;
void main(void) {
vec4 smpColor = texture2D(texture, vUv);
gl_FragColor = smpColor;
}
</script>