首页 > 解决方案 > 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%')

标签: sqloracle

解决方案


看来你想要的是 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%'

推荐阅读