用关联查询,必须在数据库中建立关系吗?
---------------------------------
我做了个会员管理,在资料修改时,需要根据Session("UserName")打开3个表
1)UserInfo(会员资料表) UserId,UserName,UserProvinceId,UserCityId等
2)UserProvince(会员所在的省份) UserProvinceId,UserProvinceName
3)UserCity(会员所在的城市) UserCityId,UserCityName
如何根据Session("UserName"),把会员资料,和UserProvinceName
,UserCityId,UserCityName通过一个语句提取出来啊
---------------------------------------------------------------
select a.userid as userid,a.username as username,b.userprovincename as userprovincename,b.usercityid as usercityid,c.usercityname as usercityname from userinfo a,userprovince b,usercity c where a.username=session("username") and a.userprovinceid=b.userprovinceid and a.usercityid=c.usercityid
---------------------------------------------------------------
select a.*,b.userprovincename as userprovincename,c.usercityname as usercityname from userinfo a,userprovince b,usercity c where a.username=session("username") and a.userprovinceid=b.userprovinceid and a.usercityid=c.usercityid