데이터 취업 스쿨 교육 18회차 내용 정리

Reallee·2023년 10월 27일
0

데이터 취업 스쿨

목록 보기
18/19
post-thumbnail

2. Mysql

4) Data

  • 데이터 추가(insert)

    • insert into tablename(column1, column2, ...) value(value1, value2, ...)
    • 모든 컬럼값을 추가할 때는 컬럼이름을 지정하지 않아도 되지만, 순서와 일치하도록 유의
  • 데이터 조회(select)

    • 선택 데이터 조회 : select column1, solumn2, ... from tablename;

    • 모든 데이터 조회 : select * from tablename;

    • 특정 조건에 부합하는 데이터 조회(where + select)
      - select column1, column2, ... from tablename where condition;

  • 데이터 수정(update + select + where)

    • update tablename set column1=value1, column2=value2 ... where condition;

  • 데이터 삭제(delete)

    • delete from tablename where condition;(where 생략 시 전체데이터 삭제)
  • 데이터 정렬(order by) : select문에서 특정 컬럼을 기준으로 정렬

    • select column1, column2, from tablename order by column1, column2 ASC|DESC;

    • default는 asc이며, order by column이 다수인 경우 차례대로 적용됨.

5) 비교연산자

  • ex) 나이가 29세인 데이터 검색
    • select name, age from tablename where age=29
  • ex) 나이가 29세가 아닌 데이터 검색
    • select name, age from tablename where age!=29
    • select name, age from tablename where age<>29
  • ex) 나이가 29세보다 큰 데이터 검색
    • select name, age from tablename where age>29
  • ex) 나이가 29세보다 작은 데이터 검색
    • select name, age from tablename where age<29
  • ex) 나이가 29세보다 크거나 같은 데이터 검색
    • select name, age from tablename where age>=29
  • ex) 나이가 29세보다 작거나 같은 데이터 검색
    • select name, age from tablename where age<=29

6) 논리연산자

  • AND 조건 : 조건(condition)을 모두 만족하는 경우 TRUE
    • select column1, column2 from tablename where condition1 and condition2..

  • OR 조건 : 조건(condition) 중 하나의 조건이라도 만족하는 경우 TRUE
    • select column1, column2 from tablename where condition1 or condition2..
    • and가 or 보다 우선처리대상이기 때문에 괄호로 묶어주지 않으면 오류 발생

  • NOT 조건 : 조건(condition)을 만족하지 않는 경우 TRUE
    - select * from tablename where not condition;

  • BETWEEN 조건 : 조건(condition)값이 범위 안에 있는 경우 TRUE
    - select column from tablename where column between value1 and value2;

profile
초심자 입니다!

0개의 댓글