전체 글
-
SQL 첫걸음 CH07. 복수의 테이블 다루기Sql 2023. 3. 17. 09:06
1 _ 집합 연산 : 데이터 베이스의 데이터를 집합으로 간주해 다루기 쉽게 하자. 또한 집합으로 취급하기 때문에 일반 연산과는 다름을 주의하자 - UNION : 두 집합을 합치는 것으로 '합집합'의 개념과 같다. 따라서 , 중복되는 값이 있다면 하나로 취급한다. - {1,2,3} 인 71_a와 {2, 10, 11}인 71_b를 UNION 하자 중복값인 2는 1개로 취급하는 열이 생성됬다. - 위와같이 열의 갯수가 다른 테이블을 UNION 하고싶다면, 열의 갯수를 맞춰줘야한다. - sample 71_a,b와 맞춰서 열의 갯수 1개가 되도록 sample31 에서 특정 열 1개를 선택해서 union 했다. ** union 구에 order by를 사용하려면 : union 구의 제일 마지막 select 구에 or..
-
nomard) Clean Up 함수React 2023. 3. 16. 16:45
Clean UP. : useEffect( 함수 , [] ) 를 사용할 때 변하는 값을 지정하지 않으면 해당 함수는 생성될 때 한번 작동하고 끝이다. 다음과 같은 함수를 해당 컴포넌트가 없어질 때 특정 함수가 작동하게 만드는 것이 Clean Up 함수이다. function something() { useEffect( () => { console.log("Hi"); return () => console.log("bye"); }, []); }; -> something 함수가 다른곳에서 불리면 console.log("Hi")를 실행하고, something 함수가 제거되면 console.log("bye")를 실행한다.
-
nomard) React 설치 및 연결React 2023. 3. 16. 12:49
리액트 설치 방법 : ReactJS 어플리케이션 개발에 도움을 준다. 1. nodejs 설치 - nodejs 홈페이지에서 설치 후 cmd로 version과 npx를 확인해주면 node를 사용할 수 있는지 확인할 수 있다. **** node를 설치하는 도중 vs code가 켜져있었다면 꼭 재부팅 해주자, 그렇지 않으면 vs code가 node를 인식할 수 없다 2. node.js 를 이용해 react 다운로드 : react는 대표적으로 node.js 와 yarn을 통해 다운로드 가능하다 - node.js 는 가급적 c 드라이브에 설치하자 - cmd에서 node -v , npm -v 명령어로 버전을 확인하는 것으로 설치가 잘 됬는지 확인할 수 있다. cmd 창에서 react를 전역으로 설치하자 (로컬로 설치..
-
input 자료형 검증 ( try - excpt )Python 2023. 3. 16. 10:54
숫자 두개를 입력받아서 + , - , * , / 할 수 있는 코드를 작성했다. 숫자를 2번 input에 입력하고, operation을 입력하면 해당 식의 결과를 출력해 준다. operation을 입력할 때 잘 못 된 값이 입력되면 Type correct information을 출력하고 while문을 다시 시작하도록 만들었다. 하지만, 숫자를 입력할 때 숫자가 아닌 다른 데이터를 입력하면 오류가 발생하고 프로그램이 멈췄다. 이를 방지하기 위해 try - except 문을 사용해서 input에 잘 못된 자료형이 입력되었을 때 이를 처리할 수 있도록 설정했다. try 문에서 input에 int가 아닌 다른 자료형이 입력될 경우 발생하는 에러 ( ValueError )를 except 문에서 예외처리하고 해당 w..
-
SQL 첫걸음 CH05. 집계와 서브쿼리Sql 2023. 3. 15. 11:18
집계함수 COUNT(집합) SUM(집합) AVG(집합) MIN(집합) MAX(집합) 1 _ 행 개수 구하기 COUNT - count 예제 - sample51의 행의 갯수를 알 수 있다. - 명령어가 from -> where -> select 순서로 진행되기 때문에 name이 A인 행 2개를 세었다. ** count() 내부에 *(전체) 로 집합을 설정하면, 하나의 행에 NULL이 아닌 열이 하나라도 있으면 모두 센다 - DISTINCT로 중복 제거 - 해당 열을 중복값 없이 출력할 수 있다. - count 내부에 distinct를 넣는 것으로 null 값을 세지 않을 수도 있다. 2 _ COUNT 이외의 집계함수 : 기본적으로 집계함수에서는 NULL 값을 무시한다 ( 완전히 존재하지 않는 것으로 취급한다..
-
SQL 첫걸음 CH04. 데이터의 추가, 삭제, 갱신Sql 2023. 3. 15. 10:23
1 _ 행 추가하기 ( INSERT ) : insert할 때는 열마다 지정되어있는 자료형, 열의 갯수, 제약을 고려해야한다. INSERT 명령 INSERT INTO 테이블명 VALUES(값1, 값2, ...) 값을 넣을 열을 지정해서 넣을 수 있다. INSERT INTO 테이블명(열명1, 열명2, ...) VALUES(값1, 값2, ...) - INSERT 방법 3가지 예제 - 디폴트 값을 넣어보자 : sample411 의 desc를 보고 같은 형태의 테이블을 생성하려면 - d열을 생성할 때 default 값을 0으로 준다 - default 값을 선언하면, 아무 값도 주지 않았을 때 NULL 이 아닌 default 값이 들어간다. 2 _ 삭제하기 DELETE DELETE FROM 테이블명 WHERE 조건..
-
SQL 첫걸음 연습문제카테고리 없음 2023. 3. 14. 16:15
Practice _ 1 emp 테이블 데이터를 사용 1) 10번 부서와 같은 일을 하는 사원의 사원번호, 이름, 급여를 조회하고 급여가 많은 순으로 출력하세요 2) 급여가 3000 이상이면, 급여 + 급여의 15% 격려금을, 급여가 2000 이상이면, 급여 + 급여의 10% 격려금을, 급여가 1000 이상이면, 급여 + 급여의 5% 격려금을, 그렇지 않으면 급여를 구하여, 이름, 직업, 급여, 격려금을 표시하시오 ** case 문 에서는 else에 조건을 넣어주는 것과, end의 별명을 지어주는 것이 좋다. 3) 사원번호, 이름, 연봉을 연봉이 높은 순으로 정렬하여 출력하세요. (연봉은 sal*12+comm 으로 계산) ** comm은 null값이 존재하는 열이기 때문에 ifnull(comm,0) 으로 ..
-
SQL 첫걸음 CH03. 정렬과 연산Sql 2023. 3. 14. 10:43
1 _ 정렬 ORDER BY 어떤 조건으로 열들을 정렬 할지 정할 수 있다. SELECT 열명 FROM 테이블명 WHRER 조건식 ORDER BY 열명 (DESC or ASC) DESC : 내림차순 ASC : 오름차순 - 내림인지 오름인지 정하지 않았다면 기본적으로 오름차순으로 지정된다 ( 작은 수가 위에 ) 숫자형 자료의 경우 오름, 내림차순은 숫자를 기준으로 한다. 년도 : 1000년 문자열 자료 칸에 숫자가 입력된 경우 이는 숫자가 아니라 문자이므로 오름차순 했을 때 다음과 같은 결과가 나온다 - a열의 경우 문자열이기 때문에 숫자를 넣어도 사전식 순서에 따라 10 , 11 보다 2가 더 크다. 2 _ 복..