![](/img/trans.png)
[英]MySQL JOIN: Only return rows where all values from right table are NULL
[英]Return all rows from one table and only a few from another with JOIN and WHERE
因此,我有兩個表“ projects”和“ overground”-運行此查詢時,我是從Overground值(40)中獲取ID的,而不是它所持有的應該是“ Forest Hill”的值。
$query = "SELECT *
FROM projects
JOIN overground ON projects.overground_id=overground.overground_id
WHERE name = 'The Horniman Museum & Gardens '";
我對查詢感到困惑,我需要“項目”中的所有行(本例中為“霍尼曼博物館和花園”中的行)以及“ overground_id”(=“森林山”)中的值。
我認為這與WHERE子句有關,但不確定。 我迷路了。 MySQL + PHP的新功能。
非常感謝您的幫助!
為什么不嘗試這樣的事情呢?
$query = "SELECT *
FROM projects, overground
WHERE projects.overground_id=overground.overground_id AND projects.name='The Horniman Museum & Gardens'";
就我個人而言,我只是希望盡可能避免顯式聯接,這只是為了簡單起見,而應避免每個聯接都有自己的聯接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.