0
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 子句”中的未知列“n.nid”。

4

3 回答 3

1

I think query must be like this. ( assuming there must be columns, name nid and vid in both tables)

Note : it is ambiguous to use use multiple table in FROM clause when we are using 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.
于 2012-09-06T05:21:21.977 回答
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运营商。

于 2012-09-06T05:14:26.603 回答
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
于 2012-09-06T05:16:59.993 回答