Zi 字媒體
2017-07-25T20:27:27+00:00
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’
寫了
5860316篇文章,獲得
23313次喜歡