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

Surely it is a stupid syntax mistake but I am a beginner with sql: 1054. Unknown column Error

我有以下查询:

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'

Image of my table

为什么会出现此错误?

这肯定是初学者在子查询或某些 table 别名中的错误。

更新:

..我现在意识到我已经颠倒了所有的AS子句.. 我修复了,现在给我这个错误:

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

更新: 我弄错了 table 前缀并修复了它,现在一切正常,非常感谢您让我注意到错误!

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