同求一条sql
create table x(
id tinyint(5) unsigned not null auto_increment,
name char(25) not null default '',
price DECIMAL(4,2) unsigned not null default '0',
primary key(id),
unique key name(name)
)engine=myisam default charset=utf8
insert into x(id,name,price)values(null,'冰红茶',3.5);
insert into x(id,name,price)values(null,'电饭锅',99);
create table y(
id tinyint(5) unsigned not null auto_increment,
individual tinyint(5) unsigned not null,
primary key(id)
)engine=myisam default charset=utf8
insert into y(id,individual)values(null,4);
insert into y(id,individual)values(null,2);
查询输出结果要这样:212 = 14+198
------解决方案--------------------
select sum(x.price*y.individual)
from x,y
where x.id=y.id