gpt4 book ai didi

mysql - 从同一个表中获取两个不同值的帖子 ID

转载 作者:行者123 更新时间:2023-11-29 21:19:26 30 4
gpt4 key购买 nike

我有两个表:

tabel1
id name address
1 ss aaaa
2 ee wwww

tabel2
id tid key value
1 1 rr ggg
2 1 ww ttt
3 2 rr ggg
4 2 ww ttt

我想获取 tabel1 的值,其中“key”是(rr AND ww),值是(ggg AND ttt)。我正在使用这个:

SELECT t1.* FROM tabel1 t1 JOIN tabel2 t2 ON  t1.id = t2.tid WHERE (t2.key = 'rr' AND t2.value ='ggg') OR (t2.key='ww' AND t2.value = 'ttt')

但我只得到这个:表1

  id name address
1 ss aaaa

最佳答案

SELECT t1.*,t2.* FROM tabel1 t1 JOIN tabel2 t2 ON  t1.id = t2.tid WHERE (t2.key = 'rr' AND t2.value ='ggg') OR (t2.key='ww' AND t2.value = 'ttt')

关于mysql - 从同一个表中获取两个不同值的帖子 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35768244/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com