BoatStandardSpecificationItem

BoatStandardSpecificationItem

我对这两个查询很生气,我无法解释为什么一个返回81行,另一个返回0。有人能帮我吗?

-- Working
SELECT * FROM
boat_standard_specification_items AS BoatStandardSpecificationItem JOIN standard_specification_items AS StandardSpecificationItem
ON(BoatStandardSpecificationItem.standard_specification_item_id = StandardSpecificationItem .id)

-- Not working
SELECT * FROM
`boat_standard_specification_items` AS `BoatStandardSpecificationItem` JOIN `standard_specification_items` AS `StandardSpecificationItem`
ON (`BoatStandardSpecificationItem`.`standard_specification_item_id` = 'StandardSpecificationItem.id')

我在Windows操作系统上,如果有什么帮助的话

最佳答案

他们不是同一个问题。在第二个问题上,你有:

ON (`BoatStandardSpecificationItem`.`standard_specification_item_id` = 'StandardSpecificationItem.id')
                                                                       ^---

注意引号的变化。单引号在查询中定义了一个字符串,因此您不是在比较两个字段,而是在比较一个字段和一个字符串。

关于mysql - 两个非常相似的查询返回不同的结果,为什么呢?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9255868/

10-15 12:36