SQL语句动态拼接1=1,1!=1的用法

a.在初始化sql语句时,在select * from table where后加上1=1恒真,防止在后面的判断中均没有为sql语句添加where限制条件而出错。

b.在select * from table where后加上1<>1恒假,用于读取表的结构,不需要读取表内容,节省开销,如:

creat table b as select * from a where 1<>1.


参考资料:

http://blog.163.com/mao_xiao_jian/blog/static/740559322010184260488/

猜你喜欢

转载自blog.csdn.net/qq_31293215/article/details/79885452
今日推荐