`
可怜狼
  • 浏览: 32423 次
  • 来自: 北京
社区版块
存档分类
最新评论

请教mysql语句的写法

    博客分类:
  • sql
阅读更多

 

表名:F_xiaoshoudan(销售表)

 

序号

字段名称

字段描述

类型

长度

KEY

1

p_id

产品号

Char

10

f

2

P_shuliang

 

int

 

 

3

jiage

 销售价

double

 

 

4

riqi  

日期

date

 

 

5

zonge

总金额

double

50

 

6

id

分销商编号

varchar

 

f

 

表名:p_infor(产品信息表)

序号

字段名称

字段描述

类型

长度

KEY

1

p_id

产品号

varchar

10

P

2

Price

出厂价

double

30

 

3

P_description

产品描述

varchar

200

 

4

date

发布日期

date

 

 

具体问题是这样的:

我要统计每种产品的利润,查询f_xiaoshoudan.P_id 和P_infor.p_id相同的产品,利用价格差 求利润

我写的sql 语句是这样的 select * from p_infor,f_xiaoshoudan where p_infor.p_id=f_xiaoshoudan.p_id

总是出错,那位仁兄指导一下

分享到:
评论
3 楼 wx_hello 2007-04-11  
spinach 写道
select a.p_id as p_id,(a.jiage-b.Price) as gain from p_infor b,f_xiaoshoudan a where a.p_id=b.p_id;
呵呵 大同小异
select p.p_id as '产品编号',(f.jiage-p.Price) as '利润'
from p_infor as p,f_xiaoshoudan as f where p.p_id=f.p_id
2 楼 spinach 2007-04-11  
select a.p_id as p_id,(a.jiage-b.Price) as gain from p_infor b,f_xiaoshoudan a where a.p_id=b.p_id;
1 楼 ddandyy 2007-04-11  
无力.......

有相同字段名  * 他怎么显示

相关推荐

Global site tag (gtag.js) - Google Analytics