开发者

Drupal - Why 'FROM node node' in the SQL query in Views?

OK... I'm delving into the bowels of Drupal in an effort to understand just what the hell is going on in there :)

I'm sure开发者_开发技巧 this is a ridiculously silly question, but when I create a node view why is the SQL query 'SELECT [....] FROM node node' and not just 'SELECT [....] FROM node' What does the second 'node' signify?

Cheers, James


"node node" is the table alias, which happens to be identical to the real table name in your query. Aliases are used for JOIN statements.

A table reference can be aliased using tbl_name AS alias_name or tbl_name alias_name:

I am guessing that drupal generates the alias even when it is not needed.


As brian_d says, the second occurrence of node is the table's alias for use in the query. It might be (though I don't know for sure) that the alias is generated as a sanitized identifier in case the actual table name is something unwieldy like Star$Linked_System:username:password@example.com:3306:/some/insane;filesystem.

For a nice name like node, the sanitized version is the same as the original.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜