一尘不染

mysql语法说明

sql

我想知道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"
        ;

阅读 143

收藏
2021-05-05

共1个答案

一尘不染

如果查看该FROM子句,则会看到以下内容:

FROM #__k2_items as a

LEFT JOIN子句中,您将看到:

LEFT JOIN #__k2_categories c ON c.id = a.catid

别名
#__k2_items表(不管它是真正的称呼)的名称a,并#__k2_categoriesc分别。在这种情况下,实际上只是保存类型并提高查询的可读性。

点将一个列名与一个表名相关联,以便MySQL知道要查找的表,以防万一您在查询中涉及的多个表中有相同名称的列。即,它 解决了列歧义

2021-05-05