gpt4 book ai didi

MySQL 创建表选择列=null 的条目(如果存在),否则另一个适当的条目

转载 作者:行者123 更新时间:2023-11-29 18:23:43 25 4
gpt4 key购买 nike

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将返回orph​​an_code,否则将返回“适当的条目”。

关于MySQL 创建表选择列=null 的条目(如果存在),否则另一个适当的条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46366967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com