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

chengzhaona 2004-08-05 03:12:52
有四个相关的表,
分别是order表,agentbalance表,product表,agent表.
order表和product表是通过pro_id相连,agent表和agentbalance 表通过age_id相连,age_id的前六位数字是和pro_id一致,现在想分别从四个表中取字段,
怎样实现啊???
...全文
89 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
你想怎么取?还有楼主什么数据库!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧