MySQL查询2内部连接?

MySQL查询2内部连接?,mysql,Mysql,我在mysql中的sql查询有问题。在sqlite3和sql server中,所有这些都可以工作 SELECT `buildings`.* FROM `buildings` INNER JOIN "floors" ON "floors"."building_id" = "buildings"."id" INNER JOIN "spaces" ON "spaces".floor_id = "floors".id

我在mysql中的sql查询有问题。在sqlite3和sql server中,所有这些都可以工作

SELECT        `buildings`.*
FROM          `buildings`
  INNER JOIN  "floors"
  ON          "floors"."building_id" = "buildings"."id"
  INNER JOIN  "spaces"
  ON          "spaces".floor_id = "floors".id
也许我需要在mysql中以其他方式进行处理


谢谢

MySQL将引号中的单词(
“floors”
)视为字符串,因此这些值不会用作表/字段名。试一试

SELECT ...
...
INNER JOIN floors ON floors.building_id = buildings.id
INNER JOIN spaces ON spaces.floor_id = floors.id
相反。仅当表/字段名为保留字时,才需要在表/字段名周围加上反勾号<代码>建筑物不是保留字,因此不需要反勾号。

可能未启用。从手册中:

如果启用ANSI_QUOTES SQL模式,也允许在双引号内引用标识符:

确保启用了ANSI_引号,或者只使用传统的倒勾(`)

从你模糊的问题来看,这也是假设我有正确的问题要解决。

SELECT        `buildings`.*
FROM          `buildings`
  INNER JOIN  `floors`
  ON          `floors`.`building_id` = `buildings`.`id`
  INNER JOIN  `spaces`
  ON          `spaces`.`floor_id` = `floors`.`id`

不要使用:“。
这是MySql中的字符串。

在MySql中运行此操作时发生了什么/不起作用?删除所有回勾和双引号,然后再试一次。MySql中的查询有什么问题?返回了任何特定错误?结果不是您期望的结果?请澄清。感谢您的帮助,有人告诉我,我可以将我的内部连接放入m中y where子句,什么是最好的?最后我删除了我的双引号和所有的工作。不要把连接函数放在where子句中。where子句只是过滤结果。你可以这样做,但从长远来看它将更难维护。
SELECT        `buildings`.*
FROM          `buildings`
  INNER JOIN  `floors`
  ON          `floors`.`building_id` = `buildings`.`id`
  INNER JOIN  `spaces`
  ON          `spaces`.`floor_id` = `floors`.`id`
SELECT        buildings.*
FROM          buildings
  INNER JOIN  floors
  ON          floors.building_id = buildings.id
  INNER JOIN  spaces
  ON          spaces.floor_id = floors.id