几个不太常用的sql

要离职了,一些资料做个备份,以后可能用得到。

由于in效率比较低,实测当in里面数据超过1000条会报错。

exists用法

select * from zhp_register_info t where exists(select 1 from zhp_register_info s where s.consumer_name=‘小米' and s.id = t.id);

max decode用法

查询出login_name为 99324623的用户名(如果不存在则为空)

select max(decode(t.login_name,'qq324623',t.consumer_name,'空'))pw from zhp_register_info t 

猜你喜欢

转载自javadazahui.iteye.com/blog/2275420