记录自己常写的一些sql语句
2014-06-26 15:26
357 查看
select a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate From android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId
and (c.checkDate>date() or c.finishDate>date() or c.checkDate='')and c.closeFlag is null and improveunit is null and a.innerId=8129
and (c.checkDate<date() and c.checkDate<>'' and c.closeFlag is null or c.finishDate<date() and c.finishDate<>'' and c.closeFlag is null) and a.innerId=8129
and c.finishDate<date() and c.finishDate<>'' and c.closeFlag is null or c.checkDate<date() and c.checkDate<>'' and c.closeFlag is null
update android_govTroubleRegCheck set checkdate='2014-05-20' where _id=119
select improveunit,finishDate,* from android_govTroubleRegCheck where finishDate>date()
finishDate<date() and finishDate<>'' and closeFlag is null or checkDate<date() and checkDate<>'' and closeFlag is null
select c.savetime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=528959 order by c.saveTime desc
Select * From MAIN.[android_govTroubleRegCheck] Limit 1000
select * from android_govCheckInspectCheckContent
select * from android_pucEntp
select * from android_insRecord
select * from android_govtroubleregcheck
select c.savetime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=528959 order by c.saveTime desc
Select * From MAIN.[android_govCheckInspectCheckContent] Limit 1000
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and (c.checkDate<=date() and c.checkDate<>'') and (c.finishDate<=date() or c.finishDate is null or c.finishDate='') and (c.closeFlag
is null or c.closeFlag='') and (c.closeFlag is null or c.closeFlag='') order by c.saveTime desc
delete from android_govtroubleregcheck
delete from android_insRecord
delete from android_pucEntp
delete from android_govCheckInspectCheckContent
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and (c.checkDate>date() or c.finishDate>date() or c.checkDate='')and c.closeFlag is null and improveunit is null order by c.saveTime
desc
//alter table android_govTroubleRegCheck add column saveTime datetime
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=6382408 and b._id=71 order by c.saveTime desc
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=5533 and closeFlag=1 order by c.saveTime desc
Select * From android_pucEntp where innerID in(select innerID from android_govTroubleRegCheck where innerID in(select innerID from android_govCheckInspectCheckContent where troubleType=1))
select a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId
select * from android_insRecord
select a.troubleType,b.entpName,a._id,a.innerId,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent a ,android_insRecord b,android_govtroubleregcheck
c,android_pucentp d where a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerID=2027291
select * from android_pucentp
(select * from a,b
如果你的a表有 x行记录,
b表y行记录,
结果有x*y行记录)
select b.entpName,b.innerID,a._id from android_insRecord a,android_pucEntp b where 1=1 and b.innerID in(select c.innerID from android_govTroubleRegCheck c where c.innerID in(select d.innerID from android_govCheckInspectCheckContent d where d.troubleType=1))
and b.entpName like '%%' order by a.savetime desc
//提出重复
//select distinct _id,innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName from
select distinct _id,innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName from(select b._id,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate
from android_govCheckInspectCheckContent a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 order by b.savetime desc )a
//判断该字段时间为当前月份,当前年份
month(checkDate) = month(getdate()) and year(checkDate) = year(getdate())
//查询该表所有字段的字段类型和字段长度
select ordinal_position,column_name,data_type,character_maximum_length from information_schema.columns where table_name = '表名'
//触发器
create trigger TR_insRecord_Delete before delete on android_insRecord for each row
begin
delete from android_govCheckInspectCheckContent where inspectID = old._id;
end
a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId
and (c.checkDate>date() or c.finishDate>date() or c.checkDate='')and c.closeFlag is null and improveunit is null and a.innerId=8129
and (c.checkDate<date() and c.checkDate<>'' and c.closeFlag is null or c.finishDate<date() and c.finishDate<>'' and c.closeFlag is null) and a.innerId=8129
and c.finishDate<date() and c.finishDate<>'' and c.closeFlag is null or c.checkDate<date() and c.checkDate<>'' and c.closeFlag is null
update android_govTroubleRegCheck set checkdate='2014-05-20' where _id=119
select improveunit,finishDate,* from android_govTroubleRegCheck where finishDate>date()
finishDate<date() and finishDate<>'' and closeFlag is null or checkDate<date() and checkDate<>'' and closeFlag is null
select c.savetime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=528959 order by c.saveTime desc
Select * From MAIN.[android_govTroubleRegCheck] Limit 1000
select * from android_govCheckInspectCheckContent
select * from android_pucEntp
select * from android_insRecord
select * from android_govtroubleregcheck
select c.savetime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=528959 order by c.saveTime desc
Select * From MAIN.[android_govCheckInspectCheckContent] Limit 1000
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and (c.checkDate<=date() and c.checkDate<>'') and (c.finishDate<=date() or c.finishDate is null or c.finishDate='') and (c.closeFlag
is null or c.closeFlag='') and (c.closeFlag is null or c.closeFlag='') order by c.saveTime desc
delete from android_govtroubleregcheck
delete from android_insRecord
delete from android_pucEntp
delete from android_govCheckInspectCheckContent
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and (c.checkDate>date() or c.finishDate>date() or c.checkDate='')and c.closeFlag is null and improveunit is null order by c.saveTime
desc
//alter table android_govTroubleRegCheck add column saveTime datetime
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=6382408 and b._id=71 order by c.saveTime desc
select c.saveTime,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where 1=1 and a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerId=5533 and closeFlag=1 order by c.saveTime desc
Select * From android_pucEntp where innerID in(select innerID from android_govTroubleRegCheck where innerID in(select innerID from android_govCheckInspectCheckContent where troubleType=1))
select a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent
a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId
select * from android_insRecord
select a.troubleType,b.entpName,a._id,a.innerId,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate,b.assistExecuter from android_govCheckInspectCheckContent a ,android_insRecord b,android_govtroubleregcheck
c,android_pucentp d where a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 and a.innerID=2027291
select * from android_pucentp
(select * from a,b
如果你的a表有 x行记录,
b表y行记录,
结果有x*y行记录)
select b.entpName,b.innerID,a._id from android_insRecord a,android_pucEntp b where 1=1 and b.innerID in(select c.innerID from android_govTroubleRegCheck c where c.innerID in(select d.innerID from android_govCheckInspectCheckContent d where d.troubleType=1))
and b.entpName like '%%' order by a.savetime desc
//提出重复
//select distinct _id,innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName from
select distinct _id,innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName from(select b._id,a._id,a.innerId,(select entpName From android_pucEntp c where c.innerID=a.innerId) entpName,b.checkUnit,c._id troubleId,a.entpTypeId,a.checkItemId,c.improveStep,c.improveUnit,c.finishDate,c.closeFlag,c.checkDate
from android_govCheckInspectCheckContent a ,android_insRecord b,android_govtroubleregcheck c where a.inspectID=b._ID and a._id=c.inspectId and a.troubleType=1 order by b.savetime desc )a
//判断该字段时间为当前月份,当前年份
month(checkDate) = month(getdate()) and year(checkDate) = year(getdate())
//查询该表所有字段的字段类型和字段长度
select ordinal_position,column_name,data_type,character_maximum_length from information_schema.columns where table_name = '表名'
//触发器
create trigger TR_insRecord_Delete before delete on android_insRecord for each row
begin
delete from android_govCheckInspectCheckContent where inspectID = old._id;
end
相关文章推荐
- 记录自己常写的一些sql语句
- 创建一张表,记录电话呼叫员的工作流水,记录呼叫员编 号、对方号码、通话开始时间、通话结束时间。建表、插数 据等最后都自己写SQL语句。
- 一些记录查询的SQL语句
- 自己用sql语句记录
- 自己整个理的一些常用sql 语句
- SQL SERVER T-SQL一些常用语句使用记录
- 一些自己用得着的SQL语句!
- 那些满脑子只考虑后台数据库的人他整天研究的就是针对自己查询一些数据的sql语句
- postgresql删除重复记录的一些相关sql语句
- 自己积累的一些SQL语句
- 自己用到的一些SQL语句汇总
- 最近整理的一些行列转换sql(有自己的,有别人的),留作记录
- 整合之前的一些学习记录 4000 3(sql常用语句)
- SQL 语句嵌套,自己记录下。
- 自己总结的一些SQL语句的基本知识
- 自己总结的一些用过的sql语句
- 自己总结的一些常用的SQL语句
- SQL语句,给自己的记录
- 读取随机记录的例子 SQL语句
- [转] 一些sql语句的详细解释