[英]How do I lock read/write to MySQL tables so that I can select and then insert without other programs reading/writing to the database?
[英]how do I write this INSERT so that it works
基本上,我想將“今天”的年,月,日分為兩個字段,如下所示。 嘗試過但不能正確處理的變體
“將膠片插入(start_year,start_month,start_day),(end_year,end_month,end_day)VALUES('$ year','$ month','$ day')”
?
"INSERT INTO film_out (start_year, start_month, start_day, end_year, end_month, end_day)
VALUES ('$year', '$month', '$day', '$year', '$month', '$day')"
INSERT INTO film_out
(start_year, start_month, start_day, end_year, end_month, end_day)
VALUES
(?,?,?,?,?,?)
您有六列,因此需要六個值。
如果您有兩組三個值,則需要重復相同的值。
您想使用綁定變量而不是直接插值(?而不是'$ year')。
不確定您的列類型是什么,所以我假設它們是數字...
INSERT INTO film_out (start_year, start_month, start_day, end_year, end_month, end_day)
VALUES (YEAR(), MONTH(NOW()), DAYOFMONTH() + 1, YEAR(), MONTH(NOW()), DAYOFMONTH() + 1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.