SELECT a.*, b.f_desc,c.dd FROM a
case when b.id<>null then JOIN b ON a.f_bid= b.f_id else ''
case when c.id<>null then JOIN c ON a.f_cid= c.f_id else ''
一个错误的sql语句,不知道该如何改,请过路的高手费费心,谢谢
case when b.id<>null then JOIN b ON a.f_bid= b.f_id else ''
case when c.id<>null then JOIN c ON a.f_cid= c.f_id else ''
一个错误的sql语句,不知道该如何改,请过路的高手费费心,谢谢
解决方案 »
- 请教句sql,有A表(零售户代码,性质)和B表(零售户代码),想把A表中这些零售户代码的性质列更新为1,他们在B表中也有对应记录 A表零售户代码重复B表无重复
- 求一SQL
- 救命啊,数据库被挂马了
- 怎么实现插入日期时间字段时,只插入日间时,字段不会默认生成1900-1-1?
- sql查询问题
- 关于连接SQL服务器中的一个小问题
- 关于数据表之间的关系图问题!
- 怎么把sql2000的数据文件.dbf和.ldf导入到sql97中,高分相送
- 这个是我感觉非常麻烦的一个查询,谢谢解答
- 如何执行处理多维数据集?
- 如何把“系统时间”变成下一个小时的时间
- 如何保存SQL查询结果?在SQLSERVER窗口上已经查到的结果 ,没有另存选项啊
case when b.id <>null then JOIN b ON a.f_bid= b.f_id else ''
case when c.id <>null then JOIN c ON a.f_cid= c.f_id else ''
一个错误的sql语句,不知道该如何改,请过路的高手费费心,谢谢SELECT a.*, b.f_desc,c.dd FROM a join b
on a.f_bid on b.f_id and b.id is not null
join c on a.f_cid=c.f_id and c.id is not null
FROM A , B, C
WHERE A.F_BID = B.F_ID AND A.F_CID = C.F_ID
AND ISNULL(B.ID,0) >0 AND ISNULL(C.ID,0) > 0
case when b.id <>null then JOIN b ON a.f_bid= b.f_id else ''
case when c.id <>null then JOIN c ON a.f_cid= c.f_id else ''
如果b.id我就不想在连接b表了;如果c.id我就不想在连接c表了...
<> 換成 is not
SELECT a.*,
(select max(b.f_desc) from b where a.f_bid= b.f_id and b.id is not null),
(select max(c.dd ) from c where a.f_bid= c.f_id and c.id is not null)
FROM a
--功力浅薄,抛砖引玉