RESULTADO DE APRENDIZAJE 2.1
Estructura la consulta de informacion mediante la seleccion , insercion eliminar y actualizacion de datos en el sistema gestor de bases de datos
TEMARIO :
A) Actualizacion mediante lenguaje SQL
*Operaciones de insertar= insert
*De eliminacion = droop
*De actualizacion = update
B) Elaboracion de consulatas mediante SQL
*Opciones seleccion
*aritmetros
*comaparacion y logicos
*logicicos
C)Manejo de disparadores de base de datos
-creacion de un disparador
-tipos de disparadores
-opereracion de case
RUBRICA %
TEMARIO :
A) Actualizacion mediante lenguaje SQL
*Operaciones de insertar= insert
*De eliminacion = droop
*De actualizacion = update
B) Elaboracion de consulatas mediante SQL
*Opciones seleccion
*aritmetros
*comaparacion y logicos
*logicicos
C)Manejo de disparadores de base de datos
-creacion de un disparador
-tipos de disparadores
-opereracion de case
RUBRICA %
- Consultas de selección 25%
- Modificación y actualización de información 30%
- Disparadores de bases de datos 25%
- Presentación de resultados 10%
- Actitudes 10%
PRACTICA 6
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 6.0.4-alpha-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use empleado;
Database changed
mysql> show databases;
+---------------------+
| Database |
+---------------------+
| information_schema |
| club |
| empleado |
| hoteles |
| libreria |
| mysql |
| phpmyadmin |
| secretaria_de_salud |
| test |
+---------------------+
9 rows in set (0.27 sec)
mysql> select * from emple;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.08 sec)
mysql> select * from depart;
+---------+---------------+-----------+
| dept_no | dnombre | loc |
+---------+---------------+-----------+
| 10 | CONTABILIDAD | SEVILLA |
| 20 | INVESTIGACION | MADRID |
| 30 | VENTAS | BARCELONA |
+---------+---------------+-----------+
3 rows in set (0.03 sec)
1;select apellido, oficio, dept_no from emple;
mysql> select apellido, oficio, dept_no from emple;
+-----------+----------+---------+
| apellido | oficio | dept_no |
+-----------+----------+---------+
| SANCHEZ | EMPLEADO | 20 |
| ARROYO | VENDEDOR | 30 |
| SALA | VENDEDOR | 30 |
| JIMENEZ | DIRECTOR | 20 |
| MARTIN | VENDEDOR | 30 |
| NEGRO | DIRECTOR | 30 |
| CEREZO | DIRECTOR | 10 |
| GIL | ANALISTA | 10 |
| TOVAR | VENDEDOR | 30 |
| ALONSO | EMPLEADO | 20 |
| JIMENO | EMPLEADO | 30 |
| FERNANDEZ | ANALISTA | 20 |
| MUNOZ | EMPLEADO | 10 |
+-----------+----------+---------+
13 rows in set (0.00 sec)
2; Select dept_no,dnombre,loc from depart;
mysql> select dept_no, dnombre, loc from depart;
+---------+---------------+-----------+
| dept_no | dnombre | loc |
+---------+---------------+-----------+
| 10 | CONTABILIDAD | SEVILLA |
| 20 | INVESTIGACION | MADRID |
| 30 | VENTAS | BARCELONA |
+---------+---------------+-----------+
3 rows in set (0.00 sec)
3; Select * from emple;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
+----------+-----------+----------+------+------------+---------+----------+---------+
4; Select * from emple order by apellido;
mysql> select * from emple order by apellido;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | 0 | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | 0 | NULL |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.00 sec)
5; Select * from emple order by dept_no desc;
mysql> select * from emple order by dept_no desc;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | 0 | 10 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.00 sec)
6; Select * from emple order by dept_no desc,apellido;
mysql> select * from emple order by dept_no desc, apellido;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.00 sec)
8; select * from emple where oficio="ANALISTA";
mysql> select * from emple where oficio="ANALISTA";
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL| 10 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
+----------+-----------+----------+------+------------+---------+----------+---------+
2 rows in set (0.00 sec)
mysql>
9; select apellido, oficio from emple where dept_no=20;
mysql> select apellido, oficio from emple where dept_no=20;
+-----------+----------+
| apellido | oficio |
+-----------+----------+
| SANCHEZ | EMPLEADO |
| JIMENEZ | DIRECTOR |
| ALONSO | EMPLEADO |
| FERNANDEZ | ANALISTA |
+-----------+----------+
4 rows in set (0.00 sec)
10; select * from emple order by apellido;
mysql> select * from emple order by apellido;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.00 sec)
11; select * from emple where oficio=’VENDEDOR’ order by apellido;
mysql> select * from emple where oficio="VENDEDOR" order by apellido;
+----------+----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+----------+----------+------+------------+---------+----------+---------+
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
+----------+----------+----------+------+------------+---------+----------+---------+
4 rows in set (0.00 sec)
12; select * from emple where dept_no=10 and oficio=’ANALISTA’;
mysql> select * from emple where dept_no=10 and oficio="ANALISTA";
+----------+----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+----------+----------+------+------------+---------+----------+---------+
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
+----------+----------+----------+------+------------+---------+----------+---------+
1 row in set (0.00 sec)
13; select * from emple where salario >200000 or dept_no=20;
mysql> select * from emple where salario > 200000 or dept_no="20";
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
+----------+-----------+----------+------+------------+---------+----------+---------+
4 rows in set (0.00 sec)
14; select * from emple order by oficio,apellido;
mysql> select * from emple order by oficio, apellido;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.03 sec)
15; select * from emple where apellido like ‘A*’;
mysql> select * from emple where apellido like "A*";
Empty set (0.03 sec)
16; select * from emple where apellido like ‘*Z’;
mysql> select * from emple where apellido like "*Z";
Empty set (0.00 sec)
17; select * from emple where apellido like ‘A*’ and oficio like ‘E*’;
mysql> select * from emple where apellido like "A*" and oficio like "E*";
Empty set (0.00 sec)
19; select * from emple where oficio="VENDEDOR" and comision > 100000;
mysql> select * from emple where oficio="VENDEDOR" and comision > 100000;
Empty set (0.00 sec)
20; select * from emple order by dept_no, apellido;
mysql> select * from emple order by dept_no, apellido;
+----------+-----------+----------+------+------------+---------+----------+---------+
| emple_no | apellido | oficio | dir | fechaalta | salario | comision | dept_no |
+----------+-----------+----------+------+------------+---------+----------+---------+
| 7782 | CEREZO | DIRECTOR | 7839 | 1991-06-09 | 2885 | NULL | 10 |
| 7788 | GIL | ANALISTA | 7566 | 1991-11-09 | 4100 | NULL | 10 |
| 7934 | MUNOZ | EMPLEADO | 7782 | 1992-01-23 | 1690 | NULL | 10 |
| 7876 | ALONSO | EMPLEADO | 7788 | 1991-09-23 | 1430 | NULL | 20 |
| 7902 | FERNANDEZ | ANALISTA | 7566 | 1991-12-03 | 3000 | NULL | 20 |
| 7566 | JIMENEZ | DIRECTOR | 7698 | 1991-04-02 | 2900 | NULL | 20 |
| 7369 | SANCHEZ | EMPLEADO | 7902 | 1990-12-17 | 1040 | NULL | 20 |
| 7499 | ARROYO | VENDEDOR | 7698 | 1990-02-20 | 1500 | 390 | 30 |
| 7900 | JIMENO | EMPLEADO | 7698 | 1991-12-03 | 1335 | NULL | 30 |
| 7654 | MARTIN | VENDEDOR | 7839 | 1991-09-29 | 1600 | 1020 | 30 |
| 7698 | NEGRO | DIRECTOR | 7698 | 1991-05-01 | 3005 | NULL | 30 |
| 7521 | SALA | VENDEDOR | 7339 | 1991-02-21 | 1625 | 650 | 30 |
| 7844 | TOVAR | VENDEDOR | 7698 | 1991-09-08 | 1350 | NULL | 30 |
+----------+-----------+----------+------+------------+---------+----------+---------+
13 rows in set (0.00 sec)
21; select emple_no,apellido from emple where apellido like ‘Z*’ and salario > 30000;
mysql> select emple_no,apellido from emple where apellido like "Z*" and salario > 30000;
Empty set (0.00 sec)
23 ;select * from emple where oficio="EMPLEADO" and salario >100000 and dept_no=10;
mysql> select * from emple where oficio="EMPLEADO" and salario >100000 and dept_no=10;
Empty set (0.00 sec)
24; select * from emple where commission is null;
mysql> select * from emple where comision is null;
PRACTICA 7
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.51b-community-nt-log MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database hos_emple;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hos_emple |
| mysql |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use hos_emple;
Database changed
mysql> create table empleado(cod_hospital integer(2), DNI varchar(20), apellido
varchar(50), funcion varchar(20), salario varchar(30), localidad varchar(20));
Query OK, 0 rows affected (0.10 sec)
mysql> insert into empleados values("1","12345","garcia_hernandez_elodio","conse
rje","1200","lorca");
ERROR 1146 (42S02): Table 'hos_emple.empleados' doesn't exist
mysql> insert into empleado values("1","12345","garcia_hernandez_elodio","conser
je","1200","lorca");
Query OK, 1 row affected (0.03 sec)
mysql> insert into empleado values("1","123456","fuentes_mermejo_zarlas","direct
or","2000","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("2","666444","gonzales_morin_maria","conseje"
,"1200","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("1","666666","castillo_morales_pedro","medico
","1200","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("2","222333","beltran_garcia_ana","medico","1
000","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("3",555441","ruis_hernadez_carlos","medico","
1900","lorca");
"> insert into empleado values("3",555441","ruis_hernadez_carlos","medico","
1900","lorca");
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 '","ru
is_hernadez_carlos","medico","1900","lorca");
insert into empleado values("' at line 1
mysql> insert into empleado values("3","555441","ruis_hernadez_carlos","medico",
"1900","lorca");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("3","999853","soriana_diaz_alejandro","direct
or","2400","cartagena");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("4","332221","meza_del_castillo_ivan","medico
","2200","lorca");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("2","222333","martin_molina_andres","medico",
"1600","curta");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("4","555444","jimenez_jimenez_dolores","conse
je","1200","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> insert into empleado values("4","222331","martinez_molina_gloria","medico
","1600","murcia");
Query OK, 1 row affected (0.00 sec)
mysql> select * from empleado;
+--------------+--------+-------------------------+----------+---------+--------
---+
| cod_hospital | DNI | apellido | funcion | salario | localid
ad |
+--------------+--------+-------------------------+----------+---------+--------
---+
| 1 | 12345 | garcia_hernandez_elodio | conserje | 1200 | lorca
|
| 1 | 123456 | fuentes_mermejo_zarlas | director | 2000 | murcia
|
| 2 | 666444 | gonzales_morin_maria | conseje | 1200 | murcia
|
| 1 | 666666 | castillo_morales_pedro | medico | 1200 | murcia
|
| 2 | 222333 | beltran_garcia_ana | medico | 1000 | murcia
|
| 3 | 555441 | ruis_hernadez_carlos | medico | 1900 | lorca
|
| 3 | 999853 | soriana_diaz_alejandro | director | 2400 | cartage
na |
| 4 | 332221 | meza_del_castillo_ivan | medico | 2200 | lorca
|
| 2 | 222333 | martin_molina_andres | medico | 1600 | curta
|
| 4 | 555444 | jimenez_jimenez_dolores | conseje | 1200 | murcia
|
| 4 | 222331 | martinez_molina_gloria | medico | 1600 | murcia
|
+--------------+--------+-------------------------+----------+---------+--------
---+
11 rows in set (0.00 sec)
mysql> select * from empleado;
+--------------+--------+-------------------------+----------+---------+-----------+
| cod_hospital | DNI | apellido | funcion | salario | localidad |
+--------------+--------+-------------------------+----------+---------+-----------+
| 1 | 12345 | garcia_hernandez_elodio | conserje | 1200 | lorca |
| 1 | 123456 | fuentes_mermejo_zarlas | director | 2000 | murcia |
| 2 | 666444 | gonzales_morin_maria | conseje | 1200 | murcia |
| 1 | 666666 | castillo_morales_pedro | medico | 1200 | murcia |
| 2 | 222333 | beltran_garcia_ana | medico | 1000 | murcia |
| 3 | 555441 | ruis_hernadez_carlos | medico | 1900 | lorca |
| 3 | 999853 | soriana_diaz_alejandro | director | 2400 | cartagena |
| 4 | 332221 | meza_del_castillo_ivan | medico | 2200 | lorca |
| 2 | 222333 | martin_molina_andres | medico | 1600 | curta |
| 4 | 555444 | jimenez_jimenez_dolores | conseje | 1200 | murcia |
| 4 | 222331 | martinez_molina_gloria | medico | 1600 | murcia |
+--------------+--------+-------------------------+----------+---------+-----------+
11 rows in set (0.00 sec)
mysql> select DNI,apellido,funcion from empleado;
+--------+-------------------------+----------+
| DNI | apellido | funcion |
+--------+-------------------------+----------+
| 12345 | garcia_hernandez_elodio | conserje |
| 123456 | fuentes_mermejo_zarlas | director |
| 666444 | gonzales_morin_maria | conseje |
| 666666 | castillo_morales_pedro | medico |
| 222333 | beltran_garcia_ana | medico |
| 555441 | ruis_hernadez_carlos | medico |
| 999853 | soriana_diaz_alejandro | director |
| 332221 | meza_del_castillo_ivan | medico |
| 222333 | martin_molina_andres | medico |
| 555444 | jimenez_jimenez_dolores | conseje |
| 222331 | martinez_molina_gloria | medico |
+--------+-------------------------+----------+
11 rows in set (0.00 sec)
mysql> select * from empleado where apellido="lorca";
Empty set (0.03 sec)
mysql> select apellido from empleado where apellido="lorca";
Empty set (0.00 sec)
mysql> select apellido from empleado where localidad="lorca";
+-------------------------+
| apellido |
+-------------------------+
| garcia_hernandez_elodio |
| ruis_hernadez_carlos |
| meza_del_castillo_ivan |
+-------------------------+
3 rows in set (0.00 sec)
mysql> select apellido from empleado where localidad="murcia";
+-------------------------+
| apellido |
+-------------------------+
| fuentes_mermejo_zarlas |
| gonzales_morin_maria |
| castillo_morales_pedro |
| beltran_garcia_ana |
| jimenez_jimenez_dolores |
| martinez_molina_gloria |
+-------------------------+
6 rows in set (0.00 sec)
mysql> select * from empleado where localidad="murcia" and salario>1500;
+--------------+--------+------------------------+----------+---------+-----------+
| cod_hospital | DNI | apellido | funcion | salario | localidad |
+--------------+--------+------------------------+----------+---------+-----------+
| 1 | 123456 | fuentes_mermejo_zarlas | director | 2000 | murcia |
| 4 | 222331 | martinez_molina_gloria | medico | 1600 | murcia |
+--------------+--------+------------------------+----------+---------+-----------+
2 rows in set (0.03 sec)
mysql> select * from empleado where localidad="murcia"and funcion="director" and salario>1500;
+--------------+--------+------------------------+----------+---------+-----------+
| cod_hospital | DNI | apellido | funcion | salario | localidad |
+--------------+--------+------------------------+----------+---------+-----------+
| 1 | 123456 | fuentes_mermejo_zarlas | director | 2000 | murcia |
+--------------+--------+------------------------+----------+---------+-----------+
1 row in set (0.00 sec)
mysql> select * from empleado where funcion="medico" and order by apellido desc;
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 'order by apellido desc' at line 1
mysql> select * from empleado where funcion="medico" order by apellido desc;
+--------------+--------+------------------------+---------+---------+-----------+
| cod_hospital | DNI | apellido | funcion | salario | localidad |
+--------------+--------+------------------------+---------+---------+-----------+
| 3 | 555441 | ruis_hernadez_carlos | medico | 1900 | lorca |
| 4 | 332221 | meza_del_castillo_ivan | medico | 2200 | lorca |
| 2 | 222333 | martin_molina_andres | medico | 1600 | curta |
| 4 | 222331 | martinez_molina_gloria | medico | 1600 | murcia |
| 1 | 666666 | castillo_morales_pedro | medico | 1200 | murcia |
| 2 | 222333 | beltran_garcia_ana | medico | 1000 | murcia |
+--------------+--------+------------------------+---------+---------+-----------+
6 rows in set (0.00 sec)
mysql> select distinct localidad from empleado;
+-----------+
| localidad |
+-----------+
| lorca |
| murcia |
| cartagena |
| curta |
+-----------+
4 rows in set (0.06 sec)
mysql> select * from empleado where salario>1500 and funcion="medico" order by salario desc;
+--------------+--------+------------------------+---------+---------+-----------+
| cod_hospital | DNI | apellido | funcion | salario | localidad |
+--------------+--------+------------------------+---------+---------+-----------+
| 4 | 332221 | meza_del_castillo_ivan | medico | 2200 | lorca |
| 3 | 555441 | ruis_hernadez_carlos | medico | 1900 | lorca |
| 2 | 222333 | martin_molina_andres | medico | 1600 | curta |
| 4 | 222331 | martinez_molina_gloria | medico | 1600 | murcia |
+--------------+--------+------------------------+---------+---------+-----------+
4 rows in set (0.00 sec)
mysql> select * from where apellido like "m*";
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 'where apellido like "m*"' at line 1
mysql> select * from where apellido like "m";
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 'where apellido like "m"' at line 1
mysql> select * from where apellido like "M*";
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 'where apellido like "M*"' at line 1
mysql> select * from empleado where apellido like "M*";
Empty set (0.22 sec)
mysql> select * from empleado where apellido like "m*";
Empty set (0.00 sec)
mysql> select * from empleado where apellido like="m*";
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 '="m*"' at line 1
mysql> select * from empleado where apellido like "m*";
Empty set (0.00 sec)
mysql> select from empleado where apellido like "m*";
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 'from empleado where apellido like "m*"' at line 1
mysql> select from empleado where apellido="m*"
->
-> select from empleado where apellido="m*";
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 'from empleado where apellido="m*"
select from empleado where apellido="m*"' at line 1
mysql> select from empleado where apellido="m*";
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 'from empleado where apellido="m*"' at line 1
mysql>
No hay comentarios.:
Publicar un comentario