database - Use different MySQL databse based on condition -
i have 2 identical databases different names. want create universal sql both. database name , use table that. can that?
code:
select @db := database(); select * @db.table1 t1 inner join @db.table2 t2 on t2.id = t1.table2_id;
thanks in advance...
the following should work you:
select @db := database(); select @stmt:= concat('select * `', @db, '`.table1 t1 inner join `', @db, '`.table2 t2 on t2.id = t1.table2_id'); prepare stmt @stmt; execute stmt;
Comments
Post a Comment