Mysql 在我的phpmyadmin中,当我使用这个过程时,我得到了这个SQL错误

Mysql 在我的phpmyadmin中,当我使用这个过程时,我得到了这个SQL错误,mysql,Mysql,错误 SQL查询: create table tbl_order_detail( o_detail_id int NOT NULL AUTO_INCREMENT, o_id int NOT NULL, p_id int NOT NULL, user_qty int NOT NULL, total int NOT NULL, primary key(o_detail_id), foreign key(o_id) references tbl_order(o_id),**strong text**

错误 SQL查询:

create table tbl_order_detail(
o_detail_id int NOT NULL AUTO_INCREMENT,
o_id int NOT NULL,
p_id int NOT NULL,
user_qty int NOT NULL,
total int NOT NULL,
primary key(o_detail_id),
foreign key(o_id) references tbl_order(o_id),**strong text**
foreign key(p_id) references tbl_product(p_id));

------------------------------------------------------------------------------

create procedure user_buy_item1(o_id int,pid int,user_qty int,total int)
begin
DECLARE total_products INT DEFAULT 0;
DECLARE new_total INT DEFAULT 0;
insert into tbl_order_detail values(null,o_id,pid,user_qty,total);
select p_qty into total_products from tbl_product where p_id = pid;
set new_total = total_products - user_qty;
update tbl_product set p_qty = new_total where p_id = pid;
end 

尝试更改您的插入查询

create procedure user_buy_item1(o_id int,pid int,user_qty int,total int)
begin
DECLARE total_products INT DEFAULT 0
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3 **

在o_detail_id中插入nul值,该值不是空的创建过程时是否使用了不同的分隔符?不建议在未指定列列表的情况下使用
insert-in
  insert into tbl_order_detail(o_id,p_id , user_qty, total ) values(o_id,pid,user_qty,total);