mysql - 创建Mysql过程

标签 mysql

我需要的帮助很少。我在mysql中有三个表。

  • 产品
  • 客户
  • 售价

通常我的经典 asp 文件中有查询,它位于底部。

set rs1=db.execute("Select id from customers order by id desc")

DO WHILE NOT rs1.EOF

set rs2=db.execute("Select id from products where order by id desc")

DO WHILE NOT rs2.EOF 

set rs3=db.execute("Select id from sellingprices where product_id="&rs2("id")&" and customer_id="&rs1("id")&" and status=1")
if rs3.eof then
db.Execute("INSERT INTO selling prices (price,product_id,status,customer_id) VALUES ('0','"&rs2("id")&"','1','"&rs1("id")&"');")
end if

rs3.close
Set rs3= Nothing

rs2.MoveNext
LOOP
rs2.close
Set rs2= Nothing

rs1.MoveNext
LOOP
rs1.close
Set rs1= Nothing

我的问题是如何使用 Mysql 创建存储过程?

最佳答案

您的查询有误

Select id from products where order by id desc

会给出错误,在where之后你应该有一些东西可以比较,但你没有。

解决方案是删除 where(假设其余代码正确)。

Select id from products order by id desc

关于mysql - 创建Mysql过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52655798/

相关文章:

mysql - 如何构建数据库以存储不同的值

mysql - sailsjs 中出现 sailsjs 1.0 模型属性类型日期列类型日期时间错误

mysql - Django 使用不同时区查询外部数据库

php - Cakephp IN 条件绕过重复 ID 来获取数据

mysql - 项目属性的 RSS 2 规范

php - 如何只打印这个echo的ID?

mysql - 存储过程中的 for 循环

php - 如何让搜索引擎索引数据库驱动的内容?

java - 如何取所选列所选行的总和值

JavaScript (Node.js)——从 MySQL 列中检索落后一天的日期