본문 바로가기

자동 업데이트 끄기
다중 for 문의 사용 public class ex04 { public static void main(String[] args) { for (int i = 2; i
Select 문 -3 (join) 커미션을 받는 모든 사원들의 이름, 연봉, 커미션을 출력하되 연봉은 ANNSAL로 출력하고 연봉을 기준으로 역순 정렬하라. 이름의 4번째 글자가 a인 사원의 이름을 조회한다. _하나당 한자리씩, a% a로 시작하는 이다. 【 JOIN 조건 】 조인기능, 여러 테이블에서 데이터를 얻는 select문의 조인 방법 [셀렉트, 프로젝션, 조인 중] ex : dept(dept_id, dept_name) , emp(e_id, dept_id) 일 때 e_id, dept_name 을 조회하고 싶을 때. 조인 기능은 두 테이블의 컬럼 dept, emp 를 하나로 합한다. from dept, emp 이렇게 합할 때는 무결성 원칙을 지키면서 행을 일치를 시켜야 함 예를들어 저기서는 두 행이 일치시키려고 할 때 dept_id..
반복문(for)문 의 사용 public class ex03 { public static void main(String[] args) { for(int i=96; i>=53; i--) { System.out.println(i); } } } for 문은 초기값, 조건문, 연산자로 나뉜다. import java.util.Scanner; public class ex03 { public static void main(String[] args) { //Scanner sc = new Scanner(System.in); for(int i=0; i
반복문과 연산자를 활용한 야구게임의 구현 import java.util.Random; import java.util.Scanner; public class theBaseball { public static void main(String[] args) { Random ran = new Random(); Scanner sc = new Scanner(System.in); int ball = 0; int strike = 0; boolean sw_itch = false; int N_1 = 0; int N_2 = 0; int N_3 = 0; int i = 0; while (sw_itch == false) { N_1 = ran.nextInt(10); N_2 = ran.nextInt(10); N_3 = ran.nextInt(10); if ((N_1 != N_..
랜덤 함수의 사용 import java.util.Random; public class ex02 { public static void main(String[] args) { Random ran = new Random(); // 랜덤 메서드 선언 int n; while (true) { int ran_num = ran.nextInt(10) + 1; // Random.nextInt의 인자는 0부터 주어진 인자까지의 범위임.. int ran_num2 = ran.nextInt(10) + 1; int ran_num3 = ran.nextInt(10) + 1; if ((ran_num != ran_num2)&&(ran_num != ran_num3)&&(ran_num2 != ran_num3)) { // not 논리 연산자 사용하여 세가지 경..
Select문 -2 【 WHERE 】 - 조건절 where 절 다음에는 조건식이 온다. where 절을 통해 검색할 조건을 넣어주었다 여기서는 employees 테이블에서 부서번호가 90인, 사원의 이름과 월급을 색인한 것이다. 여기서 90은 절대적인 숫자데이터이므로 리터럴 속성을 가진다. 모든 옵션들을 제외하면, 각 절의 머리에는 컬럼 명이 붙는다 『 where 절 유의사항 』 ○ 값이 문자나 날짜인 경우 반드시 '' (작은 따옴표)로 명시, 숫자는 하지 않음 ○ 문자의 비교는 아스키를 기반으로 하기 때문에, 대소문자를 구분한다. (table에 저장된 데이터 포맷을 그대로 사용) 『 where 절 비교연산자 』 =, >, >=, not where salary where -> select 순서이므로 as를 통해 컬럼이름을 ..
반복문(While)문 의 사용 for : 일정 횟수 (1~ 1000 등) 반복 시킬때 유용 while : 사용자가 입력한 지점까지 반복 public class ex06_01 { public static void main(String[] args) { int i = 0; int j = 0; int sum = 0; while(i < 100) { i++; sum += i; System.out.println(i+"번째계산"+sum); } } } while 문을 이용하여 1부터 100의 수 까지 더하는 예제 import java.util.Scanner; public class ex06_02 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(..