create table if not exists table1
(key ind_name(some_id))
select *
from table0
group by some_id;
if (there is an appropriate entry with column1 NULL) : select it
else : select any another appropriate entry
非常感谢您的帮助,因为我对如何在 MySQL 中编写此内容感到困惑。
更新:我最终创建了一个表 table0_temp,其中的条目按照我想要的方式排序,然后在上面的查询中使用它。
create
temporary table if not exists table0_temp
select * from table0
order by column1 asc;
最佳答案
我不确定您在问什么,但我猜您正在搜索以下内容:
SELECT COALESCE(orphan_code ,'appropriate entry');
如果COALESCE不为空,则COALESCE将返回orphan_code,否则将返回“适当的条目”。
关于MySQL 创建表选择列=null 的条目(如果存在),否则另一个适当的条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46366967/