我正在尝试使用 MySQL 插入两个不同的数据库;-
`$this->sql = "INSERT INTO tblfixedfare SELECT NULL, MAX(FixedFareID)+1, '1', '$fieldDay' FROM tblfixedfare UNION SELECT NULL, MAX(FixedFareID)+1, '2', '$fieldNight' FROM tblfixedfare,INSERT INTO tblfixedfaresetup SELECT NULL, MAX(FixedFareID)+1, '$fieldFrompc', '1', '2' FROM tblfixedfaresetup UNION SELECT NULL, MAX(FixedFareID)+1, '$fieldTopc', '2', '2' FROM tblfixedfaresetup";`
每次插入都没有问题,因为两者都分别将两行插入每个表中。
我如何让这两个同时执行?目前我收到以下错误:
语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解在附近使用的正确语法
'INSERT INTO tblfixedfaresetup SELECT NULL, MAX(FixedFareID)+1, 'DE115', '1', '2'' at line 2SQL: INSERT INTO tblfixedfare SELECT NULL, MAX(FixedFareID)+1, '1', '20' FROM tblfixedfare UNION SELECT NULL, MAX(FixedFareID)+1, '2', '30' FROM tblfixedfare UNION
INSERT INTO tblfixedfaresetup SELECT NULL, MAX(FixedFareID)+1, 'DE115', '1', '2' FROM tblfixedfaresetup UNION SELECT NULL, MAX(FixedFareID)+1, 'DE116', '2', '2' FROM tblfixedfaresetup`