[英]How to use AS in SQL INNER JOIN?
我是Mysql的新手。 我有多個表,我想將它們全部加入。 我為此使用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 ";
在這里我面臨一個問題,我在每個表中都有一個列名標題。 我想在命令中使用AS。 就像在Outlook表中一樣,列名是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>' ;
請幫我
您說過每張桌子,我知道什么:
隨意添加其他列。
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.