sql_CONCAT拼接SUBSTR截取

CONCAT和SUBSTR不一樣的數據庫有不一樣的語法。sql

(1)CONCAT數據庫

MySQL: CONCAT( )code

Oracle: CONCAT( ), ||blog

SQL Server: +io

(2)SUBSTRast

MySQL: SUBSTR( ), SUBSTRING( )class

Oracle: SUBSTR( )語法

SQL Server: SUBSTRING( )im

(3)具體用法如例:數據

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

查詢結果:EastBoston

SELECT Region_Name || ' ' || Store_Name FROM Geography  WHERE Store_Name = 'Boston';

查詢結果:East Boston

SELECT Region_Name + ' ' + Store_Name FROM Geography WHERE Store_Name = 'Boston';

查詢結果:East Boston

SELECT SUBSTR (Store_Name, 3) FROM Geography WHERE Store_Name = 'Los Angeles';

查詢結果:s Angeles

SELECT SUBSTR (Store_Name, 2, 4) FROM Geography WHERE Store_Name = 'San Diego';

查詢結果:an D

相關文章
相關標籤/搜索