About the reference of variables in the mysql5.5 database.
1. There is a database called test_num_base, which has a test table.
I want to get test data through variables.
select * from test_num_base.test;
Use variables:
set @A=test_num_base;
But when accessing again, use: select * from @A.test;
Error report: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@A' at line 1
If you use the splicing method to set:
set @B=concat('test_num_base.' 'test');
Access: select * from @B;
Still reporting an error.
Please explain how to correct it, thank you very much!
About the use of database variables.
为情所困2017-05-31 10:39:04
Only parameters can reference variables. Table names, views and data dictionaries cannot use variables directly. They can only be used through dynamic sql splicing