mysql 数据相加_mysql,php_mysql查询将两列数值相加问题,mysql,php,sql - phpStudy
mysql查詢將兩列數值相加問題
如圖所示:
我希望加一個total_price列,值為price+price2的和,這個應該怎么寫SQL;
select * from ims_goods_1 where price!=0 and price2!=0;
奉上SQL文件:
/*
Navicat MySQL Data Transfer
Source Server : car
Source Server Version : 50518
Source Host : wsy19950503.mysql.rds.aliyuncs.com:3306
Source Database : car
Target Server Type : MYSQL
Target Server Version : 50518
File Encoding : 65001
Date: 2015-06-11 15:40:28
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `ims_goods_1`
-- ----------------------------
DROP TABLE IF EXISTS `ims_goods_1`;
CREATE TABLE `ims_goods_1` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL COMMENT '1為小保養,2為電瓶',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名稱',
`price` int(4) NOT NULL COMMENT '產品價格',
`price2` int(4) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of ims_goods_1
-- ----------------------------
INSERT INTO `ims_goods_1` VALUES ('1', '1', '曼牌Mann', '70', '0');
INSERT INTO `ims_goods_1` VALUES ('2', '1', '馬勒', '29', '0');
INSERT INTO `ims_goods_1` VALUES ('13', '1', '漢格斯特Hengsr', '68', '0');
INSERT INTO `ims_goods_1` VALUES ('4', '2', '嘉實多 金嘉護SN 10W-40', '152', '0');
INSERT INTO `ims_goods_1` VALUES ('5', '2', '嘉實多 磁護SN 5W-40', '248', '110');
INSERT INTO `ims_goods_1` VALUES ('6', '2', '嘉實多 極護SN 0W-40', '376', '125');
INSERT INTO `ims_goods_1` VALUES ('7', '2', '殼牌 黃喜力HX5 10W-40', '138', '0');
INSERT INTO `ims_goods_1` VALUES ('8', '2', '殼牌 灰喜力ULTRA 5W-40', '380', '0');
INSERT INTO `ims_goods_1` VALUES ('10', '2', '美孚 美孚1號 0W-40', '368', '113');
相關閱讀:
handlebars模板文件依賴處理
CSS z中 [style] 的寫法是什么意思
extjs combo 強制刷新store
Jquery如何判斷當前頁面是否在首頁?
webstorm的structure面板中這些標志都是什么意思?
如何讓百度收錄網站內容和icon?
請教APP集成支付寶,服務端該怎么設計呢?
Flask Web開發 9.3節 角色驗證 return self.role is not None and \
如何吧 javascript的 異步API 變成為同步的?
chat列表,每兩個人只對應一條記錄,mysql如何查詢?
ubuntu系統中nginx配置問題
為什么auto fract = 8.25f/2.5聲明了一個double?
windows10重置以后,啟動進不了系統?
scrapy新建項目報錯
nodejs不能讀取oracle數據庫完整數據?
mysql讀取語句錯誤
關于android的activity中camera預覽問題,涉及activity生命周期
div中如何實現背景圖沾滿整個瀏覽器視窗?
\"(.*?)\" 請問這個正則表達式是什么意思
flask中,如何在首頁實現文章圖片簡略表示
總結
以上是生活随笔為你收集整理的mysql 数据相加_mysql,php_mysql查询将两列数值相加问题,mysql,php,sql - phpStudy的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自适应高度表格_【干货分享】Word制作
- 下一篇: mysql 没有选择数据库_没有选择数据