数据库优化union连表查询返回同一个字段

来源:互联网 发布:淘宝优惠券链接转换器 编辑:程序博客网 时间:2024/04/29 08:00

在数据库数据不大的情况下可以使用unionall对数据库进行操作,避免多次对数据库进行连接

select t.userid,t.phone from table1 t where t.isacceptmsg = 1 and policecatename = ? " +

             "union all select t.LOGINNAME as userid,MOBILE as phone from table2 t union all" +
             " select t.ID as userid , t.POLICETEL as phone from table3  t where to_char(t.ZBTIME,'yyyy-MM-dd')=? ";

0 0
原创粉丝点击