먼저 −
를 생성해 보겠습니다.mysql> create table DemoTable1431 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeCountryName varchar(20) -> ); Query OK, 0 rows affected (0.62 sec)
insert −
를 사용하여 테이블에 일부 레코드 삽입mysql> insert into DemoTable1431(EmployeeName,EmployeeCountryName) values('Adam Smith','AUS'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1431(EmployeeName,EmployeeCountryName) values('Chris Brown','US'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1431(EmployeeName,EmployeeCountryName) values('John Doe','UK'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1431(EmployeeName,EmployeeCountryName) values('Chris Brown','AUS'); Query OK, 1 row affected (0.17 sec)
select −
를 사용하여 테이블의 모든 레코드 표시mysql> select * from DemoTable1431;
이것은 다음과 같은 출력을 생성합니다 -
+------------+--------------+---------------------+ | EmployeeId | EmployeeName | EmployeeCountryName | +------------+--------------+---------------------+ | 1 | Adam Smith | AUS | | 2 | Chris Brown | US | | 3 | John Doe | UK | | 4 | Chris Brown | AUS | +------------+--------------+---------------------+ 4 rows in set (0.00 sec)
다음은 중복 열 값이 있는 MySQL 테이블에서 특정 행을 가져오는 쿼리입니다. -
mysql> select * from DemoTable1431 where EmployeeName='Chris Brown' and EmployeeCountryName='AUS';
이것은 다음과 같은 출력을 생성합니다 -
+------------+--------------+---------------------+ | EmployeeId | EmployeeName | EmployeeCountryName | +------------+--------------+---------------------+ | 4 | Chris Brown | AUS | +------------+--------------+---------------------+ 1 row in set (0.00 sec)