我想要在由其 url 标识的给定行中包含非空值的列的列名,例如:- www.facebook.com。查询的输出应该是电子邮件,密码
你可以做这样的事情
select url, group_concat(null_col separator ',')
from (
select url, 'username' null_col from yourTable where username is null union all
select url, 'phone' from yourTable where phone is null union all
select url, 'email' from yourTable where email is null union all
select url, 'password' from yourTable where password is null union all
select url, 'login' from yourTable where login is null
) t1
group by url
请注意,在同一列中存储多个值是一个众所周知的坏主意,因为它使连接、过滤或对该列执行任何其他操作变成了一场噩梦。
如果该连接是您需要的最终结果,则上述查询应该可以解决问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句