[英]Insert statement using MySql
create table enquiry (
eqid integer not null auto_increment primary key,
question varchar(500),
cusID integer(100),
tpid integer(100),
staffid integer(100)
);
alter table enquiry add foreign key(tpid) references tourpackage (tpid) ON DELETE CASCADE ON UPDATE CASCADE;
alter table enquiry add foreign key(staffid) references staff (staffid) ON DELETE CASCADE ON UPDATE CASCADE;
alter table enquiry add foreign key(cusID) references customer (cusID) ON DELETE CASCADE ON UPDATE CASCADE;
insert into enquiry
values (0, "What is the minimum travel group size?",0,0,0);
insert into enquiry
values (0, "Can we return at a later date?",0,0,0);
insert into enquiry
values (0, "I would like to use my KrisFlyer miles points to redeem an air ticket. Is it possible?",0,0,0);
我在插入查詢值時遇到問題。錯誤狀態無法添加或更新子行。
您的插入內容可能應如下所示:
insert into enquiry (question)
values ('What is the minimum travel group size?');
您不應該插入自動遞增的主鍵中。 讓數據庫在那里為您完成工作。
我猜想其他列的“ 0”值旨在表示“無參考”。 如果是這樣,讓數據庫只插入NULL
。 否則,您需要確保每個參考表都有一個“ 0”值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.