I just use the following query but it shows error. Any suggestions?
INSERT INTO test1.`tbl_news`.`file`
SELECT * FROM test2.`tbl_download_media`.`media`
WHERE TYPE = 'event'
Here I want to copy data from table tbl_download_media
which have column media
and type event
of DB test2 to DB 'test1' having table tbl_news
with column file
Here is the error:
Error Code: 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 '.file select * from nic_data.tbl_download_media.media where type = 'event' at line 1
Your insert
statement has some minor syntaxis
errors. This is the corrected version:
INSERT INTO test1.tbl_news(`file`)
SELECT media FROM test2.tbl_download_media
WHERE TYPE = 'event'
Now, if you want to update based on same id
for event
type:
UPDATE test1.tbl_news AS b
INNER JOIN test2.tbl_download_media AS g
ON (b.id = g.id)
SET b.file = g.media
WHERE TYPE = 'event'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.