首页 > 解决方案 > 如何删除 MySql 子查询中的冗余数据

问题描述

我有两个表,并且有 Mysql 查询

select x.column1 as 'id', y.column1 as 'name' from (select id from table1 limit 1) as x, (select name from table2 limit 5) as y;

在上述情况下,子查询 1 返回 1 行,子查询 2 返回 5 行,输出如下

id     name
101    AAA
101    BBB
101    CCC
101    DDD
101    EEE

但我的期望就像

id     name
101    AAA
null   BBB
null   CCC
null   DDD
null   EEE

如何在 MySql 中获得此输出?提前致谢。

标签: mysql

解决方案


推荐阅读