gpt4 book ai didi

php - MySQL 从 database.table 中选择记录(数据库名称包含 '-' )

转载 作者:行者123 更新时间:2023-11-29 01:50:27 25 4
gpt4 key购买 nike

我想从另一个数据库中获取行,所以我创建了查询:

SELECT * FROM database-test.users

MySQL 结果错误:

Database_Exception [ 42000 ]: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '-test.users' at line 1

如何解决?

谢谢回复

最佳答案

你需要像下面那样做(在表名周围使用反引号):-

SELECT * FROM `database-test`.users

或者

SELECT * FROM `database-test`.`users`

关于php - MySQL 从 database.table 中选择记录(数据库名称包含 '-' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45729380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com