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.
I am getting an error
Unknown column 'n.nid' in 'on clause'.
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.
Try this:
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
Basically, moved node n
near to the INNER JOIN
operator.
You need to use AS
in the query. Please use the following query :
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.