[MSSQL] SELECT문 사용하기
MSSQL SELECT
--전체 (SELECT ALL)
SELECT * FROM [TABLE NAME]
Example)
SELECT * FROM tblTEST
Result)
--특정 Column부르기 (SELECT specific column)
SELECT [COLUMN NAME] FROM [TABLE NAME]
Example)
SELECT firstColumn FROM tblTEST
Result)
--2개 이상의 특정 Column부르기 (SELECT more than 2 columns)
SELECT [COLUMN NAME 1],[COLUMN NAME 2] FROM [TABLE NAME]
Example)
SELECT firstColumn, thirdColumn FROM tblTEST
Result)
--특정 갯수만 부르기 (SELECT with limit rows)
SELECT TOP 3 * FROM [TABLE NAME]
Example)
SELECT TOP 3 * FROM tblTEST
Result)
--조건으로 부르기 (SELECT with condition, Using WHERE)
SELECT * FROM [TABLE NAME]
WHERE [COLUMN NAME 1] = '[CONDITION]'
Example)
SELECT * FROM tblTEST WHERE firstColumn = '4th'
Result)
Example)
SELECT * FROM tblTEST WHERE seq >= '4'
Result)
-- 별칭 사용 (Using Nickname)
SELECT [COLUMN NAME 1],[COLUMN NAME 2] AS [NICK NAME] FROM tblTEST
Example)
SELECT firstColumn, thirdColumn AS NICKAAA FROM tblTEST
Result)
'DataBase > MSSQL' 카테고리의 다른 글
[MSSQL] DELETE문 사용하기 (0) | 2016.11.09 |
---|---|
[MSSQL] UPDATE문 사용하기 (0) | 2016.11.08 |
[MSSQL] INSERT문 사용하기 (0) | 2016.11.08 |
[MSSQL] CREATE문 사용하기 (0) | 2016.11.07 |
[MSSQL] SQL이란 (0) | 2016.10.19 |
댓글