日期:2014-05-17  浏览次数:20639 次

求解释下面的sql语句
select t.*,t.c_fundcode||'-'||t1.c_fundname c_fundname from tsplitschema t,tfundinfo t1 where 1=1 and t.c_fundcode=t1.c_fundcode and t.c_dealflag='0'

------解决方案--------------------
1 = 1 在拼凑字符串的时候用 ,后面的句子可以固定用 where 1 = 1 and 条件1 and 条件2 and 。。。
如果没有 1 = 1 没有条件时就会变成 select * from tb where --报错
 有条件时 select * from tb where and 条件1 --报错
当然这两种情况都可以处理,最方便就是加 1 = 1