mysql更新/替换语法 [英] mysql update/replace syntax

查看:108
本文介绍了mysql更新/替换语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了跟踪我的访客购买了多少水果,我使用了一个mySQL数据库

(2列:水果和数量)....所以我们可以制作这些以下

mySQL查询以某种方式工作?


(访客购买5个苹果):

替换为fruit_database set fruit =''apple '',数量=数量+

5;


(访客购买7个苹果):

替换为fruit_database set fruit = ''apple'',数量=数量+

7;


(访客买1葡萄):

替换为fruit_database set fruit =''grape'',数量=数量+

1


谢谢!

To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?

(visitor buys 5 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
5;

(visitor buys 7 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
7;

(visitor buys 1 grape):
replace into fruit_database set fruit = ''grape'' , quantity = quantity +
1

Thanks!

推荐答案

Westcoast Sheri写道:
Westcoast Sheri wrote:
为了跟踪我的访客购买了多少水果,我使用了一个mySQL数据库
(2栏:水果 ;和数量)....所以我们可以使这些跟随我们的mySQL查询wo不知何故?

(访客购买5个苹果):
替换为fruit_database set fruit =''apple'',数量=数量+
5;

(访客购买7个苹果):
替换为fruit_database set fruit =''apple'',数量=数量+
7;

(访客购买1个葡萄):
替换成fruit_database set fruit =''grape'',数量=数量+
1

谢谢!
To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?

(visitor buys 5 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
5;

(visitor buys 7 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
7;

(visitor buys 1 grape):
replace into fruit_database set fruit = ''grape'' , quantity = quantity +
1

Thanks!




你是基本的sql语法吗?


更新fruit_database设置数量=数量+ 5其中fruit ='''苹果''


你好吗?如何从php访问mysql?

http://www.php。 net


Steve



are you after basic sql syntax?

update fruit_database set quantity = quantity + 5 where fruit = ''apple''

are you after how to access mysql from php?

http://www.php.net

Steve


" Westcoast Sheri" < SH ********* @ nospamun8nospam.com>在消息中写道

news:41 *************** @ nospamun8nospam.com ...
"Westcoast Sheri" <sh*********@nospamun8nospam.com> wrote in message
news:41***************@nospamun8nospam.com...
跟踪多少我的访客购买的水果,我使用的是mySQL数据库
(2栏:水果和数量)....所以我们能不能以某种方式使这些以下的mySQL查询工作?

(访客购买5个苹果):
替换为fruit_database set fruit =''apple'',数量=数量+
5;

(访客购买7苹果):
替换成fruit_database set fruit =''apple'',数量=数量+
7;

(访客买1葡萄):
替换成fruit_database set fruit =''grape'',quantity = quantity +
1
To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?

(visitor buys 5 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
5;

(visitor buys 7 apples):
replace into fruit_database set fruit = ''apple'' , quantity = quantity +
7;

(visitor buys 1 grape):
replace into fruit_database set fruit = ''grape'' , quantity = quantity +
1




你正在从错误的角度处理这个问题。您应该查询

客户销售记录并从中生成摘要信息。


INSERT INTO销售(客户,产品,数量)价值

(''



You are approching this from the wrong angle. You should be quering the
customer sales records and producing summary information from that.

INSERT INTO sales (customer, product , qty) VALUES
(''


customer'',''
customer'',''


这篇关于mysql更新/替换语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆