SELECT * FROM NOTICE WHERE 1 = 1 AND (Z_STATUS = 1 AND RELEASE_DEPT_ID = '-1' AND IS_ISSUE = 1 OR INSTR(RELEASE_DEPT_ID, '109') > 0) AND ID = '9F754701039E4903811E57589B19B18A' ORDER BY ISSUE_DATE DESC
select a.id as aid,b.id as bid,a.city,a.cang,a.sid,a.time as atime,b.time as btime,a.price as aprice,b.price as bprice,a.pm as apm,b.pm as bpm from (select id,city,cang,sid,time,price,@rank:=@rank+1 as pm from cai,(SELECT @rank:=0) B group by id,ci
复制表结构 CREATE TABLE 新表 SELECT * FROM 旧表 where 1=2 复制表结构和数据CREATE TABLE 新表 SELECT * FROM 旧表 查询重复数据: select user_name,count(*) as count from user_table group by user_name having count>1; 比较日期,转换成时间戳UNIX_TIMESTAMP() select * from Table where UNIX_TIMESTA
1.查询条件的先后顺序 有多个查询条件时,要把效率高能更精确筛选记录的条件放在后边.因为MySQL解析sql语句是从后往前的(不知是否准确). 例: select a.*,b.* from UsrInf a,OrgInf b where LogNam='njnydx9' and b.OrgId=a.blnorg SQL语句从后往前解析,把LogNam='njnydx9'换到后边,避免了更多结果集的连接,提高了执行效率 2.in的效率问题 看网上都说in相当于多个条件的or.实际测试后发现in的执
Hibernate执行sql语句:BasicServiceImpl basicServiceImpl = new BasicServiceImpl();String hql = "select * from AccountInfo where selfId='0000100003' or(left(selfId,10)='0000100004' and nodeSum=0)"; TManager tManager = TManagerImpl.getInstance();List ac