为什么我会收到此错误
Syntax error or access violation: 1327
Undeclared variable: database1 (SQL: SELECT * INTO `database1`.dbo.`tablename` FROM `database2`.dbo.`tablename`
在同一台服务器上复制数据库时?
答案 0 :(得分:0)
$newdatabase = 'newdatabase';
$tablename = 'users';
$olddatabase= 'existingdatabase';``
$results = DB::unprepared("CREATE TABLE $newdatabase.$tablename LIKE $olddatabase.$tablename") ;
$sql = "INSERT INTO `$newdatabase`.`$tablename` SELECT * from `$olddatabase`.`$tablename`";
$data = DB::insert($sql);