可以通过内部连接查询Mysql吗

时间:2021-01-03 16:42:14

i would get details from two MySQL tables

我将从两个MySQL表中获得详细信息

tables structure as shown

表结构如图所示

table:App
|AppID|AppName|AppType|

table:AppRelease
|AppReleaseID|AppID|ReleaseDate|ReleaseVersion|

and written query as shown below

以及如下所示的书面查询

$query="
  SELECT
    A.*,
    B.ReleaseDate,
    B.ReleaseVersion
  FROM       App AS A
  INNER JOIN AppRelease AS B
  WHERE A.AppID = B.AppID
"; 

i get the values when appid is in both tables

当appid在两个表中时,我将获得值

but i also want to get values from App table though i dont have data in AppRelease release table

但是我也想从App table中获取值,虽然我没有关于这个清单的数据

is it possible to write query please help me

是否可以写查询,请帮助我

1 个解决方案

#1


7  

Your requirement shouldn't be inner join.

您的需求不应该是内部连接。

Use left join:

使用左加入:

$query= "SELECT A.*,B.ReleaseDate,B.ReleaseVersion
             from App as A LEFT JOIN AppRelease as B 
             ON A.AppID=B.AppID";

#1


7  

Your requirement shouldn't be inner join.

您的需求不应该是内部连接。

Use left join:

使用左加入:

$query= "SELECT A.*,B.ReleaseDate,B.ReleaseVersion
             from App as A LEFT JOIN AppRelease as B 
             ON A.AppID=B.AppID";