很好的一天。
例如,我有一个表,其中有两个字段refid和checksum
我想得到所有校验和匹配特定ID的refid
|refid|checksum| |1 | abc |2 | def |3 | hij |4 | def |5 | hij
I then have the refid that i want to match. So if i have refid 2I want to get all rows that match the checksum colum of the row that matches 2
In 2 queries i would do
Select Checksum FROM t1 WHERE refid = 2
SELECT * FROM t1 WHERE checksum = <result of query 1>
我想在一个查询中完成此操作
最佳答案
你可以用两种方法
年
SELECT * FROM t1 WHERE checksum IN
(Select Checksum FROM t1 WHERE refid = 2)
或:
限制
SELECT * FROM t1 WHERE checksum =
(Select Checksum FROM t1 WHERE refid = 2 Limit 1)
关于mysql - MySQL根据其他查询的结果检查其他行是否具有相同的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22703505/