본문 바로가기
728x90

데이터베이스4

[DB] SQL 기본 조건문(CASE WHEN, JOIN, UNION, GROUP BY, HAVING) CASE WHEN SELECT CustomerName, City, Country FROM Customers ORDER BY (CASE WHEN City is NULL Then Country ELSE City END); 명령어 해석 Customers 테이블에서 CustomerName, City, Country 속성을 가지고 있는 데이터 조회를 쿼리한다. 단 아래의 조건으로 정렬하여 조회 값을 가져온다. City 가 null 이라면 Country 기준으로 정렬한다. 그렇지 않다면 City 기준으로 정렬한다. JOIN 기준을 가지고 데이터 결합 SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Custom.. 2020. 12. 26.
[DB] SQL 기본 함수(문자, 숫자, 날짜, 시간, 문자 처리 함수) 문자 CHAR(value) : 2000 bytes VARCHAR2(value) : 4000 bytes 숫자 INT 날짜 DATE() 시간 TIME() 문자열 처리 함수 CONCAT('a', 'b') : 'ab' LOWER('ABCDE') : 'abcde' UPPER('abcde') : 'ABCDE' INITCAP('abcde') : 'Abcde' SUBSTR('SQL Study', 1, 3) : 'SQL' REPLACE REPLACE('SQL Study', 'Study', 'Lite') : 'SQL Lite' REPLACE('SQL Study', SUBSTR('SQL Study', 0, 3), 'DB') : 'DB Study' LENGTH('SQL') : 3 COUNT : 개수 INSTR('abcde',.. 2020. 12. 26.
[DB] INSERT, UPDATE, CREATE, DROP 기본 문법 아래 사이트에서 제공하는 데이터베이스를 기본으로 스터디하였다. https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all SQL Tryit Editor v1.6 WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object. WebSQL is supported in Chrome, Safari, Opera, and Edge(79). If you use another browser you will still be able to use our Try SQL Editor, but a different ver www.w3schools.co.. 2020. 12. 26.
[DB] SELECT 기본 문법 아래 내용은 w3schools 의 SQL 파트의 DB에서 Products 테이블을 기준으로 공부하였다. https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all SQL Tryit Editor v1.6 WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object. WebSQL is supported in Chrome, Safari, Opera, and Edge(79). If you use another browser you will still be able to use our Try SQL Editor, but a differe.. 2020. 12. 19.
728x90