♣
求一SQL语句!
select * from wl_company
where c_id not in (select c_id from wl_userinfo where c_id is not null)
有谁能提供一句实现同样功能的sql语句,但效率要高!
上面那条特慢!
谢谢!!
· 网友精彩回答:
select * from w1_userinfo left join w1_company on w1_userinfo.c_id=w1_company.c_id where
w1_company.c_id is null
对不起,这句可能符合你的要求
select c.c_id from w1_company as c
left join w1_userinfo as u on c.c_id=u.c_id
where u.c_id is null
上面这个查询如果w1_userinfo.c_id字段有重复数据,查询结果会增多。试试下面这个:
select c.c_id
from w1_company as c
left join (select distinct c_id from w1_userinfo) as u
on c.c_id=u.c_id
where u.c_id is null;
不过搂主可以试试在子查询里用 distinct ,可能效率会高一点。
- 更多问题:
- · 问身边牛人没有解决的关于进程间通信的问题
- · 一个SQL问题
- · 在C#里怎么读去EXCEL的单元格里的数据,
- · null,false,true与NULL,FALSE,TRUE的区别
- · 奇怪的jsp+tomcat5.0.18中文乱码问题!!!
- · 学了asp,asp.net,jsp;做了网站,OA;现在一个小地方混,工资,待遇,前景比较迷茫
- · 请问一下这种xml文件怎么来读取啊
- · 给你一个网址,然后怎么样把这个网址里的所有内容打印出来?
- · asp.net程序出错问题
- · 请教关于CPtrArray的问题
- · servlet 中的Dll调用问题 ,多谢了!
- · 问一下如何history.back(-1)的网页过期问题
- · 有没有学习算法的书,是用C#实现的,中英文都很好
- · 求助rational xde for vs.net2003的价格?
- · 请请[天使淑女猫]进来,我道歉~~
- · 下面这段代码错在哪里?

