我有两张桌子
table: t1
id|name|type
1 | a |0
2 | b |1
3 | c |0
4 | d |0
...
table: t2
uid|type
4 |1
3 |0
...
我想计算或获取表 t1 中的记录有 type = 1 并且记录有 id = uid 表 t2 有 type = 1
在一个查询中计算或获取记录的最佳方法是什么
$type = 1;
$count = mysql_num_rows(mysql_query("Select * .... Where type = $type ")); //$count = 2
$result = mysql_query("Select * ... order by id desc "); // $result include record in table t1 has id (4, 2) b/c order by id desc
编辑:我做了一个 sql 在http://www.sqlfiddle.com/#!2/8847d1/12
中尝试
但我不能这样做
我希望记录结果看起来像(所有列都有我上面的条件)
id|name|
4 |d |
2 |b |
怎么做 谢谢