The document contains the SQL commands and output from a MySQL session where a user creates databases and tables to store employee and department data. They define the table schemas, insert sample data, and run queries to retrieve the data. Key actions include:
- Creating an "employee" database and "employees" and "departments" tables with various columns
- Inserting test employee and department records
- Running SELECT queries to view the inserted data and filter based on department location
The document contains the SQL commands and output from a MySQL session where a user creates databases and tables to store employee and department data. They define the table schemas, insert sample data, and run queries to retrieve the data. Key actions include:
- Creating an "employee" database and "employees" and "departments" tables with various columns
- Inserting test employee and department records
- Running SELECT queries to view the inserted data and filter based on department location
The document contains the SQL commands and output from a MySQL session where a user creates databases and tables to store employee and department data. They define the table schemas, insert sample data, and run queries to retrieve the data. Key actions include:
- Creating an "employee" database and "employees" and "departments" tables with various columns
- Inserting test employee and department records
- Running SELECT queries to view the inserted data and filter based on department location
The document contains the SQL commands and output from a MySQL session where a user creates databases and tables to store employee and department data. They define the table schemas, insert sample data, and run queries to retrieve the data. Key actions include:
- Creating an "employee" database and "employees" and "departments" tables with various columns
- Inserting test employee and department records
- Running SELECT queries to view the inserted data and filter based on department location
varchar(20),phone_number long,hireDate date,jobId int,salary,managerId int,departmentId int,primary key(employeeId)); ERROR 1046 (3D000): No database selected mysql> use employee; Database changed mysql> create table employees(employeeId int,firstName varchar(20),lastName varchar(20),email varchar(20),phone_number long,hireDate date,jobId int,salary,managerId int,departmentId int,primary key(employeeId)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'managerId int,departmentId int,primary key(employeeId))' at line 1 mysql> create table employees(employeeId int,firstName varchar(20),lastName varchar(20),email varchar(20),phone_number long,hireDate date,jobId int,salary float(5),managerId int,departmentId int,primary key(employeeId)); Query OK, 0 rows affected (0.02 sec)
mysql> create table
employees(employeeId,firstName,lastName,email,phone_number,hireDate,jobId,salary,managerId, departmentId) values(1,"balaji","prasath","[email protected]",94872,'17-07- 2020',101,25000,11,01); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'firstName,lastName,email,phone_number,hireDate,jobId,salary,managerId,department' at line 1 mysql> insert into employees(employeeId,firstName,lastName,email,phone_number,hireDate,jobId,salary,managerId, departmentId) values(1,"balaji","prasath","[email protected]",94872,'17-07- 2020',101,25000,11,01); ERROR 1292 (22007): Incorrect date value: '17-07-2020' for column 'hireDate' at row 1 mysql> insert into employees(employeeId,firstName,lastName,email,phone_number,hireDate,jobId,salary,managerId, departmentId) values(1,"balaji","prasath","[email protected]",94872,'2020-07- 17',101,25000,11,01); Query OK, 1 row affected (0.00 sec) mysql> insert into employees(employeeId,firstName,lastName,email,phone_number,hireDate,jobId,salary,managerId, departmentId) values(2,"ravi","kumar","[email protected]",948772,'2020-09-21',121,28000,12,02); Query OK, 1 row affected (0.00 sec)
mysql> insert into values (departId,departName,locationId) values (2,'production',1700);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values (departId,departName,locationId) values (2,'production',1700)' at line 1 mysql> insert into departments (departId,departName,locationId) values (2,'production',1700); ERROR 1146 (42S02): Table 'employee.departments' doesn't exist mysql> insert into departemnts (departId,departName,locationId) values (2,'production',1700); Query OK, 1 row affected (0.01 sec)
mysql> insert into departemnts (departId,departName,locationId) values (2,'production',
mysql> select 8 from departments where locationId=1700;
+---+ |8| +---+ |8| |8| +---+ 2 rows in set (0.00 sec)
mysql> select * from departments where locationId=1700;
+----------+------------+------------+ | departId | departName | locationId | +----------+------------+------------+ | 2 | production | 1700 | | 5 | backend | 1700 | +----------+------------+------------+ 2 rows in set (0.00 sec)
mysql> select * employeeId,firstName,lastName from employees where departId in(2,5) order by
firstName,lastName; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'employeeId,firstName,lastName from employees where departId in(2,5) order by fir' at line 1 mysql> select * from employees; +------------+-----------+----------+---------------------+--------------+------------+-------+-------- +-----------+--------------+ | employeeId | firstName | lastName | email | phone_number | hireDate | jobId | salary | managerId | departmentId | +------------+-----------+----------+---------------------+--------------+------------+-------+-------- +-----------+--------------+ | 1 | balaji | prasath | [email protected] | 94872 | 2020-07-17 | 101 | 25000 | 11 | 1| | 2 | ravi | kumar | [email protected] | 948772 | 2020-09-21 | 121 | 28000 | 12 | 2| | 3 | sunil | kumar | [email protected] | 94889 | 2020-11-21 | 131 | 36000 | 16 | 5| +------------+-----------+----------+---------------------+--------------+------------+-------+-------- +-----------+--------------+ 3 rows in set (0.00 sec)
mysql> select * employeeId,firstName,lastName from employees where departId in (2,5) order by
firstName,lastName; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'employeeId,firstName,lastName from employees where departId in (2,5) order by fi' at line 1 mysql> select employeeId,firstName,lastName from employees where departId in (2,5) order by firstName,lastName; ERROR 1054 (42S22): Unknown column 'departId' in 'where clause' mysql> mysql> select employeeId,firstName,lastName from employees where departmentId in (2,5) order by firstName,lastName; +------------+-----------+----------+ | employeeId | firstName | lastName | +------------+-----------+----------+ | 2 | ravi | kumar | | 3 | sunil | kumar | +------------+-----------+----------+ 2 rows in set (0.00 sec)
mysql> mysql> select employeeId,firstName,lastName from employees where departmen (2,5)
order by firstName,lastName;mysql> select employeeId,firstName,lastName from employees where departId in (2,5) order by fir mysql> select employeeId,firstName,lastName from employees where departmentId imysqelect departId from departments eh Id in (2,5) order by firstName,lastName;mysql> select employeeId,firstName,lastName from employees where departId in (2,5) order by firstName,las -> -> ; ERROR 1054 (42S22): Unknown column 'departId' in 'where clause' mysql> select employeeId,firstName,lastName from employees where departId in (semysql> lect deemployeeId,firstName,lastName from employees where departId in (select departId from departments where locatiomysql> select -> -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 mysql> select employeeId,firstName,lastName from employees where departmentId in(select departId from departments where locationId=1700) order by firstName,lastName; +------------+-----------+----------+ | employeeId | firstName | lastName | +------------+-----------+----------+ | 2 | ravi | kumar | | 3 | sunil | kumar | +------------+-----------+----------+ 2 rows in set (0.00 sec)