![](/img/trans.png)
[英]Subtract two fields in two different tables to insert different into a third field in second table
[英]combine date and time of two fields then insert into third field of table
我有tbl1
其中有場date
和time
.Suppose還有另一個表tbl2
與現場date_time
。現在,我想從繁重的數據date
和time
的領域tbl1
,將它們結合起來,並插入到date_time
的領域tbl2
,在Ymd H:i:s
格式或曾經格式possible.Please有人幫助,從一個表插入到另一個是不是讓我頭疼的一個問題,但相結合的那么兩場插入到另一個表中的值?
您應該從tbl1連接日期和時間字段。
像這樣:
INSERT INTO tbl2 (datetime_field)
VALUES (SELECT CONCAT(date_filed, ' ', time_field)
FROM tbl1 WHERE pk_field = your_condition);
注意:子選擇只能返回一個結果!
INSERT INTO tbl2 (date_time)
SELECT CONCAT(`date`, ' ', `time`)
FROM tbl1
WHERE your_condition
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.