当我运行此查询时,我得到的products.total大于10000。
SELECT p.id
, p.title
, a.country
, p.total
FROM products p
JOIN product_tags pt
ON p.id = pt.product_id
JOIN address a
ON p.address_id = a.id
JOIN product_styles ps
ON p.id = ps.product_id
WHERE p.allow = 'Yes'
AND ps.styles in ('Abstract Expressionism')
AND p.total between 500 and 10000
AND p.title LIKE '%abstract%'
OR pt.tags LIKE '%abstract%'
OR a.country LIKE '%abstract%'
OR p.subject LIKE '%abstract%'
GROUP
BY p.id
答案 0 :(得分:1)
检查以下更新版本或条件是否存在问题。
select DISTINCT products.id,
products.title,
address.country,
products.total
from products
inner join product_tags on products.id = product_tags.product_id
inner join address on products.address_id = address.id
inner join product_styles on products.id = product_styles.product_id
where products.allow = 'Yes' and product_styles.styles in ('Abstract Expressionism')
and products.total between 500 and 10000
and (products.title like '%abstract%' or product_tags.tags like '%abstract%' or address.country like '%abstract%' or products.subject like '%abstract%' )
答案 1 :(得分:0)
SELECT DISTINCT p.id
, p.title
, a.country
, p.total
FROM products p
JOIN product_tags pt
ON p.id = pt.product_id
JOIN address a
ON p.address_id = a.id
JOIN product_styles ps
ON p.id = ps.product_id
WHERE p.allow = 'Yes'
AND ps.styles IN ('Abstract Expressionism')
AND p.total BETWEEN 500 AND 10000
AND
( p.title LIKE '%abstract%'
OR pt.tags LIKE '%abstract%'
OR a.country LIKE '%abstract%'
OR p.subject LIKE '%abstract%'
);