急,想取四个表中的字段怎样写sql语句?????????????

chengzhaona 2004-08-05 03:12:52
有四个相关的表,
分别是order表,agentbalance表,product表,agent表.
order表和product表是通过pro_id相连,agent表和agentbalance 表通过age_id相连,age_id的前六位数字是和pro_id一致,现在想分别从四个表中取字段,
怎样实现啊???
...全文
66 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xzq686 2004-08-05
太乱了。看不清,把上面的四个表order,agentbalance,product,agent从头开始命名为a,b,c,d
select (你所要的那些字段前缀带上表名)from a inner join b inner join c inner join b on a.pro_id=c.pro_id and b.age_id=d.age_id and left(age_id,6)=left(pro_id,6)
回复
xzq686 2004-08-05
四个表关联:

select a.order_id,a.order_sum,a.order_provindetime,b.bal_balanceforecase,b.bal_rebate,c.proname,d.agename from order as a inner join prodcut as c inner join agentbalance as b inner join agentas d where a.pro_id=c.pro_id and b.age_id=d.age_id and left(age_id,6)=left(pro_id,6)
回复
xzq686 2004-08-05
晕,这么长:
try:
select a.order_id,a.order_sum,a.order_provindetime,b.bal_balanceforecase,b.bal_rebate,c.proname,d.agename from order as a inner join prodcut as c,agentbalance as b inner join agentas d where a.pro_id=c.pro_id and b.age_id=d.age_id
回复
dcwang 2004-08-05
sql = "select * from a,b,c,d where a.pro_id = b.pro_id and c.age_idc = d.age_id "
回复
chengzhaona 2004-08-05
a,b,c,d 四个表是具有联系的,通过字段pro_id,age_id相连,age_id的前六位数字是和pro_id一致
回复
baby21st 2004-08-05
sql = "select * from a,b,c,d where a.字段a = b.字段b and c.字段c = d.字段d"
回复
chengzhaona 2004-08-05
我想取order表中order_id,order_sum,order_provindetime字段,取agentbalance表中的bal_balanceforecast,bal_rebate字段,取product表中的proname,取agent表中的agename字段,然后把各个字段用表格的形式显示出来??
回复
skyboy0720 2004-08-05
你想怎么取?还有楼主什么数据库!
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-08-05 03:12
社区公告
暂无公告