最佳答案
使用联合查询:
select topic1 as topic from t union
select topic2 as topic from t union
select topic3 as topic from t union
select topic4 as topic from t union
select topic5 as topic from t union
select topic6 as topic from t union
select topic7 as topic from t union
select topic8 as topic from t;
如果您不需要 NULL
,请包含 WHERE
子句:
select topic1 as topic from t where topic1 is not null union
select topic2 as topic from t where topic2 is not null union
select topic3 as topic from t where topic3 is not null union
select topic4 as topic from t where topic4 is not null union
select topic5 as topic from t where topic5 is not null union
select topic6 as topic from t where topic6 is not null union
select topic7 as topic from t where topic7 is not null union
select topic8 as topic from t where topic8 is not null;
关于mysql - 如何从行和列中一起选择不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38187670/