我需要从表中获取一行,如果store_id =1中有值,则返回该行,否则,返回行store_id = 0。
SELECT *
FROM `catalog_category_entity_int`
WHERE (store_id = 1 OR store_id = 0)
AND attribute_id = 67发布于 2021-01-20 00:57:28
使用限制
SELECT *
FROM `catalog_category_entity_int`
WHERE (store_id = 1 OR store_id = 0)
AND attribute_id = 67
order by store_id desc limit 1发布于 2021-01-21 01:48:46
我的解决方案是这样的:
SELECT *, IF(store_value.value IS NULL, default_value.store_id, store_value.store_id) AS `store_id` FROM `catalog_category_entity_int` AS `default_value` LEFT JOIN `catalog_category_entity_int` AS `store_value` ON store_value.attribute_id = 67 AND store_value.store_id = 1 WHERE default_value.attribute_id = 67 AND default_value.store_id = 0感谢你的帮助
https://stackoverflow.com/questions/65795897
复制相似问题