sqlite 兩個欄位合併(相加/組合)的搜尋語法

sqlite 兩個欄位合併(相加/組合)的搜尋語法

sqlite 兩個欄位合併(相加/組合)的搜尋語法

資料來源:http://www.2cto.com/database/201202/119922.html

使用 || 符號即可連接

 

Ex:

SELECT People_List.uid  AS uid ,People_List.C_name || “~” || P_Department.Name AS CP_name

FROM People_List,P_Department

WHERE  People_List.PD_uid=P_Department.uid

 

————————————————————————

其他資料庫:

MySQL: CONCAT( )

Oracle: CONCAT( ), ||

SQL Server: +

 

Geography 表格

Region_Name Store_Name
East Boston
East New York
West Los Angeles
West San Diego

 

例子1

MySQL/Oracle:

SELECT CONCAT(Region_Name, Store_Name) FROM Geography 
WHERE Store_Name = ‘Boston’;

結果:

 

‘EastBoston’

 

例子2

Oracle:

SELECT Region_Name || ‘ ‘ || Store_Name FROM Geography 
WHERE Store_Name = ‘Boston’;

結果:

‘East Boston’

 

例子3

SQL Server:

SELECT Region_Name + ‘ ‘ + Store_Name FROM Geography 
WHERE Store_Name = ‘Boston’;

結果:

‘East Boston’
 

 

 

One thought on “sqlite 兩個欄位合併(相加/組合)的搜尋語法

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *