我有一个构建CMS的项目。我们提供了一些功能..在下面。我希望有人向我解释一下'''''' cm'意思/代表什么?
function getAllPosts() {
global $db;
$sql = "SELECT p.*, ca.catName, COUNT(commentID) as numComments
FROM posts p
LEFT JOIN categorys ca USING (categoryID)
LEFT JOIN comments cm USING (postID)
";
if ($_GET['catID'] != ''){
$catID = (int)$_GET['catID'];
$sql .= "WHERE categoryID = $catID ";
}
$sql .= "GROUP BY postID
ORDER BY postDate DESC";
$qry = mysqli_query($db, $sql);
$result = array();
while ($row = mysqli_fetch_assoc($qry)) {
$result[] = $row;
}
if (count($result) > 0) {
return $result;
}
return false;
}
答案 0 :(得分:0)
它们是一种不使用整个表名来编写查询的简短方法。 (表别名)
E.g。 SELECT a.name, a.surname FROM very_long_name_of_my_table [AS] a
而不是
SELECT very_long_name_of_my_table.name, very_long_name_of_my_table.surname FROM very_long_name_of_my_table
答案 1 :(得分:-1)