当然这是一个愚蠢的语法错误,但我是sql:1054的初学者未知列错误

igsr9ssn  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(337)

我有以下疑问:

SELECT
    INIZIO.idinizio AS id,
    inizio,
    fine,
    barca
FROM
    (
        (
        SELECT
            ID AS idinizio ,
            meta_value AS inizio,
            term_taxonomy_id AS barca
        FROM
            wp_posts
        INNER JOIN wp_postmeta ON(
                ID = post_id AND post_type = 'tribe_events' AND meta_key = '_EventStartDate' AND(
                    post_status = 'publish' OR post_status = 'private'
                )
            )
        INNER JOIN wp_term_relationships ON(
                ID = object_id
            )
        ) AS INIZIO
INNER JOIN
        (
        SELECT
            ID AS idfine,
            meta_value AS fine
        FROM
            wp_posts
        INNER JOIN wp_postmeta ON(
                ID = post_id AND post_type = 'tribe_events' AND meta_key = '_EventEndDate' AND(
                    post_status = 'publish' OR post_status = 'private'
                )
            )
        ) AS FINE
ON (idinizio = idfine)
)

当我运行它时,我得到以下错误:

Error Code: 1054. Unknown column 'idinizio' in 'field list'

我的table的图像
为什么我会犯这个错误?
在子查询或某些表别名中,这肯定是初学者的错误。
更新:
.. 我现在意识到我把所有的as子句都颠倒了。。我修正了这个错误:


# 1054 - Colonna sconosciuta 'posts.idinizio' in 'on clause'

更新:我把表的前缀弄错了,我把它修好了,现在一切正常,非常感谢你让我注意到错误!

hfsqlsce

hfsqlsce1#

你应该替换 idinizio 带的列 ID 作为 ON (INIZIO.ID = FINE.idfine) 在底部,因为您已经将该列别名为 ID 在上面的内部查询中。

相关问题