多表查询代码
select [qz_lh].*,[lh].[juguangdu],[yingshoujia],[jinhuojia],[zhekou],[lingshoujia],[kucun].[shangpinID],[shuliang],[pihao],[leixing] from [qz_lh],[lh],[kucun] where [qz_lh].[ID]=5 and [kucun].[leixing]=’老花’ and cangkuID=’001′ and [qz_lh].zhuangtai <>’0′
select * from kucun where leixing =’老花’
select [qz_lh].*,[lh].*,[kucun].* from [qz_lh],[lh],[kucun] where [kucun].[shangpinID]=[lh].[pinpaiID] and kucun.leixing=’老花’
select * from lh
/*6|老花2|2|1.25*/
select [qz_jp].*,[jp].[qiujing],[zhujing],[yingshoujia],[jinhuojia],[zhekou],[lingshoujia],[kucun].[shuliang],[pihao],[leixing] from [qz_jp],[jp],[kucun] where [jp].pinpaiID = [kucun].shangpinID and cangkuID=’001′ and [qz_jp].ID=1 and [qz_jp].zhuangtai <>’0′ and [kucun].[leixing]=’镜片’
复制表代码
insert into xiaoshoudanb([danhao],[cangku],[shangpin],[leixing],[danwei],[yingshoujia],[lingshoujia],[shuliang],[zongji],[lirun],[jingshouren],[shijian],[kahao],[xingming],[lianxifangshi],[jifen],[lururen],[quhuoshijian],[ticheng]) select [xiaoshoudana].[danhao],[cangku],[shangpin],[leixing],[danwei],[yingshoujia],[lingshoujia],[shuliang],[zongji],[lirun],[jingshouren],[shijian],[kahao],[xingming],[lianxifangshi],[jifen],[lururen],[quhuoshijian],[ticheng] from [xiaoshoudana]
求和代码:
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [jp],[kucun] where [jp].pinpaiID = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [yx],[kucun] where [yx].pinpaiID = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [jj],[kucun] where [jj].pinpai = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [lh],[kucun] where [lh].pinpaiID = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [tyj],[kucun] where [tyj].pinpai = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [hl],[kucun] where [hl].pinpai = [kucun].[shangpinID] and [cangkuID]=’001′
select sum([jinhuojia]*[shuliang]) as [chengben],sum([lingshoujia]*[shuliang]) as [lingshou] from [qtshangpin],[kucun] where [qtshangpin].pinpai = [kucun].[shangpinID] and [cangkuID]=’001′