更新一个可能的解决方案可能是在客户端上按空格拆分您的字符串,然后使用这样的查询(如果您需要在列中完全匹配)
SELECT *
FROM products
WHERE product_id IN (123, 94)
OR price IN (123, 94)
或者
SELECT *
FROM products
WHERE 93 IN (product_id, price, productname)
OR 123 IN (product_id, price, productname)
OR 'cooldrink' IN (product_id, price, productname)
这是SQLFiddle演示
现在,如果您需要确保同一行的两个关键字都是 price 或 product_id
SELECT *
FROM products
WHERE (product_id = 123 AND price = 94)
OR (product_id = 94 AND price = 123)
这是SQLFiddle演示
另一种方法,如果部分匹配是可以的,接近这个
SELECT product_id, price, productname
FROM
(
SELECT p.*, ',' || product_id || ',' || price || ',' || productname || ',' details
FROM products p
)
WHERE details LIKE ',%94%,'
OR details LIKE ',%123%,'
OR details LIKE ',%cool%,'
这是SQLFiddle演示