프로시저2 [MySQL] 함수, 프로시저, 세션변수 쿼리문 연습문제 1. Data Table 2. 프로시저 연습문제 /*프로시져1. 고객을 새로 등록*/ use jin; drop procedure if exists newCustomer; delimiter // create procedure newCustomer( newCustID int, newName varchar(40), newAddress varchar(40), newPhone varchar(20)) BEGIN declare myCount int; select count(*) into myCount from customer where custID like newCustID; if myCount != 0 then update customer set name = newName, address = newAddress, .. Coding 공부/MYSQL 2024. 4. 3. [MySQL] 내장 함수, 세션 변수, 프로시저, 함수 예제 1. MySQL 내장함수 예제 -- 내장함수 select abs(-78);/*절대값 내장함수*/ select round(4.875, 1);/*소수점 반올림해서 첫째자리까지 표현함*/ select * from book; /*책 이름 중에 '야구'를 '농구'로 변환해 result grid에 출력*/ select bookid, replace(bookname, '야구', '농구') bookname from book;/*원본 데이터는 변하지 않는다.*/ select * from customer; /*성을 따로 잘라내어 표시하고 해당 성을 가진 사람이 몇 명인지 표시하는 코드*/ select substr(name, 1, 1) as '성', count(*) as '인원' from customer group by su.. Coding 공부/MYSQL 2024. 4. 3. 이전 1 다음 728x90 반응형