我想知道a。*,c.name,… a.access等的含义。换句话说,当我在点和点的功能之前添加字母时,我指的是什么。
这是我发现这种情况的代码示例:
$query = "SELECT a.*, c.name as categoryname,c.id as categoryid, ". "c.alias as categoryalias, c.params as categoryparams". " FROM #__k2_items as a". " LEFT JOIN #__k2_categories c ON c.id = a.catid"; $query .= " WHERE a.published = 1" ." AND a.access <= {$aid}" ." AND a.trash = 0" ." AND c.published = 1" ." AND c.access <= {$aid}" ." AND c.trash = 0" ;
如果查看该FROM子句,则会看到以下内容:
FROM
FROM #__k2_items as a
在LEFT JOIN子句中,您将看到:
LEFT JOIN
LEFT JOIN #__k2_categories c ON c.id = a.catid
这 别名 的#__k2_items表(不管它是真正的称呼)的名称a,并#__k2_categories以c分别。在这种情况下,实际上只是保存类型并提高查询的可读性。
#__k2_items
a
#__k2_categories
c
点将一个列名与一个表名相关联,以便MySQL知道要查找的表,以防万一您在查询中涉及的多个表中有相同名称的列。即,它 解决了列歧义 。