gpt4 book ai didi

sql - 如何选择sql复杂Query where Condition And or

转载 作者:行者123 更新时间:2023-12-02 15:19:20 24 4
gpt4 key购买 nike

<分区>

我的 table 是

   ID       ATTRID    VALSTR   
1771373 1 1234
1771373 3 510
1771373 7 2016
1771373 8 05
1777623 3 5003
1777623 7 2016
1777623 8 05
1778103 3 520
1778103 7 2016
1778103 8 06

我要选择条件

                       AttrId = 3 AND ValStr = 510 
AttrId = 7 AND ValStr = 2016
AttrId = 8 AND ValStr = 05

我写了这个但是运行不正确

SELECT *
FROM Table
WHERE ((AttrID = 3 AND ValStr ='510') OR
(AttrID = 7 AND ValStr ='2016') OR
(AttrID = 8 AND ValStr ='05')
) AND
DefID = 1375552

如何写这个查询?你能帮帮我吗?

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