Mysql 按联接表值选择
我加入了一些表,这样我就有了这样的结果表Mysql 按联接表值选择,mysql,sql,Mysql,Sql,我加入了一些表,这样我就有了这样的结果表 IDnameval 1n1false 1n2true 1N3真 第二条真理 2N2真的 2n3真 3n1false 3N2真 3n3真 一个可能的解决方案是 select distinct id from yourTable t1 join yourTable t2 on t1.id = t2.id where t1.name = n1 and t1.val = 'true' and t2.name = n
IDnameval
1n1false
1n2true
1N3真
第二条真理
2N2真的
2n3真
3n1false
3N2真
3n3真
一个可能的解决方案是
select distinct id
from yourTable t1
join yourTable t2
on t1.id = t2.id
where t1.name = n1 and t1.val = 'true' and
t2.name = n2 and t2.val = 'true';
一个可能的解决办法是
select distinct id
from yourTable t1
join yourTable t2
on t1.id = t2.id
where t1.name = n1 and t1.val = 'true' and
t2.name = n2 and t2.val = 'true';