sql - Include multiple choices in 'LIKE'
问题描述
I am trying to display all vendors where the first address is a PO Box but I am struggling how to format that using LIKE. In my table the PO Box can be formatted any of those 3 ways but I am not sure how to include all 3 in the LIKE. What I currently have here fives me a "missing right parenthesis" error
SELECT vendor_name, vendor_address1, vendor_address2
FROM ap_vendors
WHERE vendor_address1 LIKE ('PO Box%', 'P. O. Box%', 'P O Box%')
解决方案
看来你想要的是 OR 逻辑
你可以这样做:
SELECT vendor_name, vendor_address1, vendor_address2
FROM ap_vendors
WHERE vendor_address1 LIKE 'PO Box%'
OR vendor_address1 LIKE 'P. O. Box%'
OR vendor_address1 LIKE 'P O Box%'
推荐阅读
- c# - 在没有提升的情况下设置系统时间窗口 10
- c# - Razor Pages - 2 个表的 EF 返回值
- loops - 通过遍历模型字典生成模型预测的数据框
- reactjs - React Context API 全局状态不会在反应中跨不同路由更新
- swift - 类 Observable 对象 @Published 变量始终为空
- google-smart-home - 其他调用短语从操作控制台中消失
- javascript - 轮播上一个和下一个按钮逻辑不起作用
- r - 如何将 tidyselect 样式的列名列表拼接到我的函数的调用中
- memory-management - 将新 Box 分配给现有变量是否会泄漏内存?
- mysql - 如何按评论数最高的顺序对帖子进行排序