国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

175. Combine Two Tables

2024-07-21 02:52:25
字體:
來源:轉載
供稿:網友

Table: Person

+-------------+---------+| Column Name | Type    |+-------------+---------+| PersonId    | int     || FirstName   | varchar || LastName    | varchar |+-------------+---------+PersonId is the PRimary key column for this table.

Table: Address

+-------------+---------+| Column Name | Type    |+-------------+---------+| AddressId   | int     || PersonId    | int     || City        | varchar || State       | varchar |+-------------+---------+AddressId is the primary key column for this table.

Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

FirstName, LastName, City, State

這里要求不論Address信息有沒有都要保留Person的信息,這里是left join.

select Person.FirstName, Person.LastName, Address.City, Address.State from Personleft join Addresson Person.PersonId=Address.PersonId;SQL 連接:

1. INNER JOIN:如果表中有至少一個匹配,則返回行;

2. LEFT JOIN:即使右表中沒有匹配,也從左表返回所有的行;

3. RIGHT JOIN:即使左表中沒有匹配,也從右表返回所有的行

來自:點擊打開鏈接


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 盘锦市| 仙游县| 丽水市| 宣汉县| 邯郸县| 安徽省| 岗巴县| 石屏县| 砚山县| 巩义市| 德化县| 稻城县| 常山县| 黔西| 长寿区| 大安市| 兴业县| 霸州市| 贵溪市| 兴国县| 康马县| 南宫市| 孝义市| 南靖县| 来安县| 石门县| 莱阳市| 鄂州市| 许昌县| 华亭县| 晴隆县| 当阳市| 五家渠市| 镇沅| 西华县| 榆林市| 萝北县| 神农架林区| 萍乡市| 宾阳县| 罗江县|