gpt4 book ai didi

mysql - sql 类函数逻辑或

转载 作者:行者123 更新时间:2023-12-01 00:37:31 25 4
gpt4 key购买 nike

select town_id,name from `soft_uni`.towns
where name like 'b%' or 'm%' or 'k%' or 'e%'

我想找到所有以 b 或 m 或 k 或 e 开头的名字,但这样它只适用于以 b 开头的城镇

最佳答案

在该查询中开始条件之前,您需要添加name like

select town_id,name from `soft_uni`.towns
where name like 'b%' or name like 'm%' or name like 'k%'
or name like 'e%'

另一种解决方案是使用 REGEXP

select town_id, name from `soft_uni`.towns
where name REGEXP '^(b|m|k|e)';

关于mysql - sql 类函数逻辑或,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44722804/

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