Mysql 检查两个字段中的匹配值
我试图想出一个查询,它将在一个表中搜索两个字段中的匹配值 例如,将tbl_id 202和tbl_id 203标识为在tbl_行和tbl_列中都具有匹配值的查询是什么 谢谢 tatty27Mysql 检查两个字段中的匹配值,mysql,Mysql,我试图想出一个查询,它将在一个表中搜索两个字段中的匹配值 例如,将tbl_id 202和tbl_id 203标识为在tbl_行和tbl_列中都具有匹配值的查询是什么 谢谢 tatty27选择T1.tbl\u id,T2.tbl\u id Select T1.tbl_id, T2.tbl_id FROM Table T1, Table T2 WHERE T1.tbl_row = T2.tbl_row and T1.tbl_col = T2.tbl_col and T1.tbl_id <&
选择T1.tbl\u id,T2.tbl\u id
Select T1.tbl_id, T2.tbl_id
FROM Table T1, Table T2
WHERE T1.tbl_row = T2.tbl_row and T1.tbl_col = T2.tbl_col and T1.tbl_id <> T2.tbl_id
从表T1到表T2
其中T1.tbl_行=T2.tbl_行和T1.tbl_列=T2.tbl_列和T1.tbl_id T2.tbl_id
这不是最干净的方法,因为它会将返回的行数加倍,但会显示重复的行数。假设表名为tbl:
选择t1,t2。从tbl t1开始,tbl t2,其中t1.tbl_行=t2.tbl_行,t1.tbl_列=t2.tbl_列 选择不同的t1.tbl\u id
select distinct t1.tbl_id
from
tbl as t1
inner join tbl as t2
on t1.tbl_row = t2.tbl_row
and t1.tbl_col = t2.tbl_col
and t1.tbl_id <> t2.tbl_id
从…起
tbl as t1
内部连接tbl为t2
在t1.tbl_行=t2.tbl_行
t1.tbl_col=t2.tbl_col
和t1.tbl_id t2.tbl_id