select (n个字段)
from b
where id in (select id from a where date between @StardDate and @EndDate and houseid=@houseid and void='0')
上面是我写的正确的sql语句;下面的sql语句加了两个表c,d;到c,d里面根据id把name查询出来,查询结果就跟前面的不一样了
理论上是一样的,根据id求name四个表:a,b,c,d
关键字:a.id=b.id;
a.houseid=c.houseid;
b.itemid=d.itemid;select (n个字段)
from a,b,c,d
where a.date between @StardDate and @EndDate and a.houseid=@houseid and a.void='0' and b.id=a.id and b.itemid=c.itemid and a.divid=d.divid
各位看看,我的sql语句改什么写啊?
解决方案 »
- 在group by 之后的Having里如何求均值
- 寻找“用T-sql语句管理SQL2000数据库的语法大全”
- 有两个问题 请大家帮忙一下
- [调查]数据量多大?是存储过程分页吗?性能怎么样?
- 如何在服务器控制非管理员用户只能看到它有管理权限的数据库呢?20分
- 请问用触发器怎么实现插入一条数据后把这条数据的标题后边括号里的内容去掉,并且替换
- 急,一个辣手问题啊!头疼死了
- 安装SQL2008出现的错误
- SQLServer数据库同步总报错:为过程或函数 sp_MSset_subscription_properties 指定的参数太多。
- 我该怎么取出sqlite3所有数据???????????/
- 升级脚本报错,求高手帮忙
- 根据数量的变化情况,如何得到该类产品总数量变化情况,如何写SQL语句,谢谢!
关键字:a.id=b.id;
a.divid=d.divid;
b.itemid=c.itemid;
from a,b,c,d
where a.date between @StardDate and @EndDate and a.houseid=@houseid and a.void='0' and b.id=a.id and b.itemid=c.itemid and a.divid=d.divid
from b
left join a on b.id=a.id
left join c on b.itemid=c.itemid
left join d on a.divid=d.divid
where a.date between @StardDate and @EndDate and a.houseid=@houseid and a.void='0'
where a.date between @StardDate and @EndDate and a.houseid=@houseid and a.void='0' and b.id=a.id --and b.itemid=c.itemid and a.divid=d.divid
from a,b--,c,d
where a.date between @StardDate and @EndDate and a.houseid=@houseid and a.void='0' and b.id=a.id --and b.itemid=c.itemid and a.divid=d.divid
select (n个字段)
from b
where id in (select id from a where date between @StardDate and @EndDate and houseid=@houseid and void='0')