我一直尝试使用 sql 查询从我的表中选择LIKE OR AND
。 我想列出产品类型bakery-catering
的所有产品,同时使用 like 从匹配的位置获取它。 但是下面的sql查询显示匹配位置中的所有产品,忽略了我想要的产品类型。
SELECT * FROM productservice
WHERE product_address LIKE "Enugu-ezike,%"
OR product_address_two LIKE "ezike district%"
OR product_description LIKE "cooking%"
AND product_type = "bakery-catering"
这将显示搜索位置中的所有产品类型。请问我该如何解决这个问题?
SELECT * FROM productService
WHERE
(
product_address LIKE 'Enugu-ezike,%' OR
product_address_two LIKE 'ezike district%' OR
product_description LIKE 'cooking%'
)
AND product_type = 'bakery-catering'
或者,如果您坚持使用双引号,那么,
SELECT * FROM productservice
WHERE
(
product_address LIKE "Enugu-ezike,%" OR
product_address_two LIKE "ezike district%" OR
product_description LIKE "cooking%"
)
AND product_type = "bakery-catering"
SELECT * FROM productservice
WHERE product_type = "bakery-catering"
AND product_address LIKE "Enugu-ezike,%"
AND product_address_two LIKE "ezike district%"
AND product_description LIKE "cooking%"
如果您有 50 行product_type = 面包店餐饮 如果您有 40 行product_type = 面包店餐饮和product_description = "烹饪%"如果您有 20 行product_type = 面包店餐饮和 product_description = 烹饪百分比和 product_address_two = "Ezike 区%">
如果您有 10 行product_type = 面包店餐饮和 product_description = 烹饪百分比和 product_address_two = "Ezike 区%" 和 product_address = "Enugu-ezike,%">
然后,该查询将仅为您提供 10 行选择条件