SQL语句分析

来源:百度知道 编辑:UC知道 时间:2024/06/23 20:25:22
麻烦帮忙分析下以下SQL
select distinct temp.编号 as 编号号 ,temp.来源 as 来源,temp.样品名称 as 样品名称,temp.单位 as

单位,temp.联系人 as 联系人,temp.应收费用 as 应收费用,temp.应用科室 as 应用科室,temp.样品类别

as 样品类别 from
(select distinct apply_form.apply_no as 编号号,Apply_Origin_No as 来源,goods as 样品名

称,applicant as 单位,word_report_record.date_print as 出证时间,contact as 联系人,fee as 应收

费用,main_dept as 应用科室,kind as 样品类别
from apply_form,word_report_record,Charge_Record

where (apply_form.apply_no=word_report_record.apply_no) and

Apply_Form.Apply_No=Charge_Record.Apply_no and

apply_form.apply_no like "24%"
and (word_report_record.date_print between '2007-01-1'and '2007-2-1')) as temp

这段语句的意思是:先从apply_form,word_report_record,Charge_Record
表中查询相关字段,做一个临时表temp,再从临时表中取数据.不知你这段查询语句是否正确,但意思就是这样的.
(select distinct apply_form.apply_no as 编号号,Apply_Origin_No as 来源,goods as 样品名
称,applicant as 单位,word_report_record.date_print as 出证时间,contact as 联系人,fee as 应收
费用,main_dept as 应用科室,kind as 样品类别
from apply_form,word_report_record,Charge_Record
where (apply_form.apply_no=word_report_record.apply_no) and
Apply_Form.Apply_No=Charge_Record.Apply_no and
apply_form.apply_no like "24%"
and (word_report_record.date_print between '2007-01-1'and '2007-2-1')) as temp --这一段是做临时表.