如何在SQLINNER JOIN中使用AS?

How to use AS in SQL INNER JOIN?

我是 Mysql 的新人。我有多个 table,我想全部加入。我为此使用 INNER JOIN。

"SELECT *
FROM table
               INNER JOIN table2
               ON table.client_id = table2.id

           WHERE table2.id= 113
           ORDER BY table.id DESC
           LIMIT 1 ";

这里我遇到一个问题,我在每个 table 中都有一个列名标题。我想在我的命令中使用 AS。就像在 outlook table 中一样,列的名称是 TITLE 我想将其用作 outlook_title。怎么可能?

我想用echo打印这样的数据

echo '<h1>' .$row["client"]. '</h1>' ;
echo '<h1>' .$row["name"]. '</h1>' ;
echo '<h1>' .$row["name"]. '</h1>' ;
echo '<h1>' .$row["ation_title"]. '</h1>' ;
echo '<h1>' .$row["look_title"]. '</h1>' ;

请帮帮我

你说每table,我知道什么:>

随意添加其他栏目。

SELECT r.title as rtitle,c.title as ctitle,
t.title as ttitle,a.title as atitle,o.title as otitle
FROM og_ratings r 
INNER JOIN og_companies c
ON r.client_id = c.id
INNER JOIN og_rating_types t
ON r.rating_type_id = t.id
INNER JOIN og_actions a
ON r.pacra_action = a.id
INNER JOIN og_outlooks o
ON r.pacra_outlook = o.id
WHERE c.id= 113
ORDER BY r.id DESC
LIMIT 1

您可以使用 AS 为您的列以及 subquery 结果提供别名

SELECT s.title as stitle,p.title as ptitle
FROM og_ratings s 
INNER JOIN og_companies p
ON s.client_id = p.id
WHERE s.id= 115