SELECT n.nid, n.title, c.field_news_date_value,
c.field_news_short_text_value, c.field_news_short_text_format
FROM node n, term_data m, term_node p
INNER JOIN content_type_news c
ON c.nid = n.nid AND c.vid = n.vid
WHERE n.type='news' AND n.status=1
ORDER BY c.field_news_date_value DESC.
我收到错误
'on clause'中的未知列'n.nid'。
答案 0 :(得分:1)
我认为查询必须是这样的。 (假设两个表中都必须有列,名称为nid
和vid
)
注意:当我们使用FROM
JOIN
子句中使用多个表是不明确的
SELECT n.nid, n.title, c.field_news_date_value,
c.field_news_short_text_value, c.field_news_short_text_format
FROM node n
INNER JOIN content_type_news c
ON c.nid = n.nid AND c.vid = n.vid
WHERE n.type='news' AND n.status=1
ORDER BY c.field_news_date_value DESC.
答案 1 :(得分:0)
试试这个:
SELECT n.nid, n.title, c.field_news_date_value, c.field_news_short_text_value, c.field_news_short_text_format
FROM term_data m, term_node p, node n INNER JOIN content_type_news c
ON c.nid = n.nid AND c.vid = n.vid
WHERE n.type='news' AND n.status=1
ORDER BY c.field_news_date_value DESC
基本上,将node n
移到INNER JOIN
运营商附近。
答案 2 :(得分:0)
您需要在查询中使用AS
。请使用以下查询:
SELECT
n.nid, n.title,
c.field_news_date_value,
c.field_news_short_text_value,
c.field_news_short_text_format
FROM
node as n, term_data as m, term_node as p
INNER JOIN
content_type_news c ON c.nid = n.nid AND c.vid = n.vid
WHERE
n.type='news'
AND n.status=1
ORDER BY
c.field_news_date_value DESC