关于SQL SERVER查询

来源:百度知道 编辑:UC知道 时间:2024/05/06 17:58:11
在同一数据库下,查询一样东西,要通过几个表来查询
我写的如下
select tx.plucode as 编码,tx.barcode as 条码,tx.pluname as 品名,tx.price as 售价,tx.spec as
规格,tx.unit as 计量单位,tx.grade as 等级,tx.produce as 产地,tj2.supcode as 供应商编码
from txtplu tx,tJhJhHead tj2,tJhJhBody tj1
where tx.plucode=999 and tx.plucode=tJ2.plucode and tJ2.billno=tJ1.billno

txtplu这个表里面有plucode值999,tJhJhHead这个表里面也有plucode值999和supcode值,tJhJhBody这个表里面有supcode,

我现在要通过tJhJhHead这个表中转得到tJhJhBody这个表里面的supcode值

具体应该怎么写?我被这几个转过去转过来,头给转大了!

申明:我是初学者!
谢谢指点!

首先确认tJ2.billno=tJ1.billno 这个关系能对应上,
既然要通过tJhJhHead这个表中转得到tJhJhBody这个表里面的supcode值,那么前边select时tj2.supcode应改成tj1.supcode,语法应该是没什么错误,你把几个表中的几个字段关系弄明白就可以了