求助:两个表的联合
原来是这样的
Sql= "select username as 用户ID,truename as 真实姓名 ,province as 省份,city as 城市,address as 通讯地址,postcode as 邮编 ,tel as 联系电话,email as 电子邮件,userwork as 工作单位,zw as 职务,dateandtime as 兑换时间 from view_giftorder where pid= "&id& " and flag=1 "&between& " order by dateandtime desc "
现在要把DV_USER表中的username与表view_giftorder中username 相同的记录的userpower也组合到查询中去.
请问应该如何组合?先谢谢了.
[解决办法]
----try--
Sql= "
select a.username as 用户ID,
a.truename as 真实姓名 ,
a.province as 省份,
a.city as 城市,
a.address as 通讯地址,
a.postcode as 邮编 ,
a.tel as 联系电话,
a.email as 电子邮件,
a.userwork as 工作单位,
a.zw as 职务,
a.dateandtime as 兑换时间
b.userpower ----- 新加的列
from view_giftorder inner join DV_USER on a.username=b.username
where pid= "&id& " and flag=1 "&between& " order by dateandtime desc "
[解决办法]
Sql= "select a.username as 用户ID,a.truename as 真实姓名 ,a.province as 省份,a.city as 城市,
a.address as 通讯地址,a.postcode as 邮编 ,a.tel as 联系电话,a.email as 电子邮件,
a.userwork as 工作单位,a.zw as 职务,a.dateandtime as 兑换时间
from view_giftorder a inner join DV_USER b on a.username=b.username
where a.pid= "&id& " and a.flag=1 "&between& "
order by a.dateandtime desc "