gpt4 book ai didi

mysql - 执行 where 子句

转载 作者:太空宇宙 更新时间:2023-11-03 11:01:23 25 4
gpt4 key购买 nike

我有这张客户表:

+----------+----------+---------+
| cliecode | cliename | deleted |
+----------+----------+---------+
| 00001 | ABC | |
| 00002 | DEF | |
| 00003 | GHI | yes |
| 00004 | JKL | |
+----------+----------+---------+

我正在执行这样的搜索查询:

SELECT * 
FROM client
WHERE deleted =''
AND cliecode LIKE '%$_POST[key]%' OR cliename LIKE '%$_POST[key]%'

我想在 like 条件之前先获取 deleted = ''。我怎样才能做到这一点?谢谢。

最佳答案

然后将您的 OR 条件分组,将它们放在括号内,

select  * 
from client
where deleted ='' and
(cliecode like '%$_POST[key]%' or cliename like '%$_POST[key]%')

关于mysql - 执行 where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15404286/

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