linux - mysql variable problem
伊谢尔伦
伊谢尔伦 2017-05-31 10:37:04
0
1
702

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.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
为情所困

Only parameters can reference variables. Table names, views and data dictionaries cannot use variables directly. They can only be used through dynamic sql splicing

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!