我有以下查询:
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'
为什么会出现此错误?
在子查询或某些表别名中肯定会是初学者的错误。
更新:
..现在我意识到我已经颠倒了所有的AS子句.. 我已修复,现在给我这个错误:
#1054 - Colonna sconosciuta 'posts.idinizio' in 'on clause'
更新: 我把表前缀弄错了,我把它改正了,现在一切正常,非常感谢你让我注意到错误!
答案 0 :(得分:0)
您应该在底部将idinizio
列替换为ID
,将ON (INIZIO.ID = FINE.idfine)
列替换为ID
,因为在上面的内部查询中,该列已被别名为IntList password = new IntList(14, 2, 12);
IntList attempt = new IntList();
boolean isLoggedIn = true;
attempt.append(14);
attempt.append(2);
attempt.append(12);
for (int i = 0; i < attempt.size(); i++)
{
if (password.get(i) != attempt.get(i))
{
isLoggedIn=false;
}
}
if (isLoggedIn)
{
println("You are logged in");
} else
{
println("Password incorrect");
}
。