mysql - mysql选择带有后备的行
问题描述
我需要从表中获取一行,如果 store_id = 1 中有值则返回该行,否则返回该行 store_id = 0。
SELECT *
FROM `catalog_category_entity_int`
WHERE (store_id = 1 OR store_id = 0)
AND attribute_id = 67
解决方案
使用限制
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
推荐阅读
- r - R - 根据单个列的多个条件从数据框中删除行
- julia - 为什么不考虑 cplex 中解决方案数量的限制?
- asp.net - ASP.NET Core - 如何压缩和调整图像大小和质量
- python - Rs deSolve 和 Pythons odeint 的区别
- javascript - JavaScript:显示是否有任何选项已赋值
- powerbi - 平均持续时间 DAX Power BI
- java - 引起:java.lang.IllegalArgumentException:transactionManager 是必需的
- c# - C#:如何在动态对象内部的数组中设置项的值?
- python - 处理像素坐标来自行列表的图像的像素值
- iis-10 - 打开 URL 重写功能时 IIS 10 崩溃?