charset=utf8;
insert into tb
(id,num)
values
('a',50),
('b',60),
('c',70),
('d',80);
1 合并 两张表格
2 合并两张表单...把相同id下的数值sum求和
发现问题
使用聚合 函数时 不许有空格
Sum(num)
Sum (num)
将会把 sum 识别为 表 报该数据库下不存在该表单错误
Error...1630(42000)
注意:如果子句里 有 order by | limit 需要 union 两边加小括号
例如
(select good_id,cat_id,goods_name...1 order by 尽量放在最后使用 即岁最终合并后的结果 进行排序
(select good_id,cat_id,goods_name,shop_price from goods _id...=where cat_id = 4 )union
(select good_id,cat_id,goods_name,shop_price from goods _id =where cat_id