You are on page 1of 9

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| agencias |

| alojamientos |

| clases |

| clientes |

| clientes1 |

| clientes2 |

| educa |

| ejemplo |

| ejercicio2 |

| embarques |

| empleado |
| empleados1 |

| empresa |

| escolares |

| escolaresI |

| hola |

| matricula |

| matricula1 |

| mysql |

| papeleria |

| performance_schema |

| phpmyadmin |

| plantillaempresa |

| prueba |

| sys |

+--------------------+

26 rows in set (0.06 sec)

mysql> use educa;

Database changed

mysql> select*from curso where cred=3 ANd cdept='PHIL';

+-----+-----------------+--------------------+------+---------+-------+

| Cno | Cnombre | Cdescp | Cred | Ctarifa | Cdept |

+-----+-----------------+--------------------+------+---------+-------+

| P11 | EMPIRISMO | VERLO PARA CREERLO | 3 | 100 | PHIL |

| P22 | RACIONALISMO | PARA USARLOS CIS | 3 | 50 | PHIL |

| P33 | EXISTENCIALISMO | PARA USARLOS CIS | 3 | 200 | PHIL |

+-----+-----------------+--------------------+------+---------+-------+

3 rows in set (0.10 sec)


mysql> select*from curso where (ctarifa >= 100) AND (ctarifa<= 500);

+-----+-----------------------+--------------------+------+---------+-------+

| Cno | Cnombre | Cdescp | Cred | Ctarifa | Cdept |

+-----+-----------------------+--------------------+------+---------+-------+

| C11 | INTROD. A LAS CC. | PARA NOVATOS | 3| 100 | CIS |

| C55 | ARQUITECT. COMPUTADOR | MAQ. VON NEUMANN | 3 | 100 | CIS |

| C66 | BASES DE DATOS RELAC. | IMPRESCINDIBLE | 3| 176 | CIS |

| P11 | EMPIRISMO | VERLO PARA CREERLO | 3 | 100 | PHIL |

| P33 | EXISTENCIALISMO | PARA USARLOS CIS | 3 | 200 | PHIL |

| T11 | ESCOLASTICISMO | PARA BEATOS | 3| 150 | THEO |

| T44 | COMUNISMO | PARA AVAROS | 6| 200 | THEO |

| C77 | GEOMETRÍA | ACTUAL | 6| 140 | CIS |

+-----+-----------------------+--------------------+------+---------+-------+

8 rows in set (0.04 sec)

mysql> use empresa;

Database changed

mysql> select nombre, cuota, ventas from repventas

-> where ventas < cuota and ventas < 300000;

+---------------+--------+--------+

| nombre | cuota | ventas |

+---------------+--------+--------+

| Bob Smith | 171428 | 142594 |

| Nancy Angelli | 285714 | 186042 |

| Mat¡as Clark | 100000 | 0|

| 35 | 103 | 15 |

+---------------+--------+--------+

4 rows in set (0.04 sec)


mysql> select nombre, cuota, ventas

-> from repventas

-> where (ventas < cuota) OR (ventas < 300000);

+---------------+--------+--------+

| nombre | cuota | ventas |

+---------------+--------+--------+

| Paul Cruz | 235715 | 286775 |

| Bob Smith | 171428 | 142594 |

| Nancy Angelli | 285714 | 186042 |

| Mat¡as Clark | 100000 | 0|

| 35 | 103 | 15 |

+---------------+--------+--------+

5 rows in set (0.00 sec)

mysql> use educa;

Database changed

mysql> select esueldo from personal

-> UNION

-> select fsueldo from claustro;

+---------+

| esueldo |

+---------+

| 53 |

| 52 |

| 51 |

| 25001 |

| 25000 |

| 54 |

| 4000 |
| 200 |

| 500 |

| 0|

| 35000 |

| 45000 |

| 36000 |

+---------+

13 rows in set (0.04 sec)

mysql> use empresa;

Database changed

mysql> select idfab, idproducto from productos

-> where precio > 200

-> UNION

-> select distinct fab, producto from pedidos where importe > 300;

+-------+------------+

| idfab | idproducto |

+-------+------------+

| ACI | 4100Y |

| ACI | 4100Z |

| BIC | 41003 |

| BIC | 41089 |

| FEA | 114 |

| IMM | 773C |

| IMM | 775C |

| IMM | 779C |

| IMM | 887P |

| IMM | 887X |

| QSA | XK47 |
| REI | 2A44G |

| REI | 2A44L |

| REI | 2A44R |

| ACI | 41004 |

| ACI | 41003 |

| ACI | 41002 |

| ACI | 4100X |

| FEA | 112 |

+-------+------------+

19 rows in set (0.15 sec)

mysql> select sueldo from personal

-> UNION ALL

-> select fsueldo from claustro;

ERROR 1146 (42S02): Table 'empresa.personal' doesn't exist

(Error 1146 MySQL por faltar tablas en la base de datos “mysql”)

mysql>

mysql> use educa;

Database changed

mysql> select cdept, cnombre from curso

-> order by cdept,cnombre;

+-------+-----------------------+

| cdept | cnombre |

+-------+-----------------------+

| CIS | ARQUITECT. COMPUTADOR |

| CIS | BASES DE DATOS RELAC. |

| CIS | CIRCUITOS DIGITALES |

| CIS | ESTRUCT. DE DATOS |

| CIS | GEOMETRÍA |
| CIS | INTROD. A LAS CC. |

| CIS | MATEMATICAS DISCRETAS |

| PHIL | EMPIRISMO |

| PHIL | EXISTENCIALISMO |

| PHIL | RACIONALISMO |

| PHIL | SOLIPSISMO |

| THEO | COMUNISMO |

| THEO | ESCOLASTICISMO |

| THEO | FUNDAMENTALISMO |

| THEO | HEDONISMO |

+-------+-----------------------+

15 rows in set (0.04 sec)

mysql> select*from curso

-> where not cdept='CIS' OR (ctarifa=0 AND cred=3);

+-----+-----------------------+--------------------+------+---------+-------+

| Cno | Cnombre | Cdescp | Cred | Ctarifa | Cdept |

+-----+-----------------------+--------------------+------+---------+-------+

| C33 | MATEMATICAS DISCRETAS | EL LENGUAJE DB2 | 3 | 0 | CIS |

| C44 | CIRCUITOS DIGITALES | AH HA! | 3| 0 | CIS |

| P11 | EMPIRISMO | VERLO PARA CREERLO | 3 | 100 | PHIL |

| P22 | RACIONALISMO | PARA USARLOS CIS | 3 | 50 | PHIL |

| P33 | EXISTENCIALISMO | PARA USARLOS CIS | 3 | 200 | PHIL |

| P44 | SOLIPSISMO | PARA MI MISMO | 6| 0 | PHIL |

| T11 | ESCOLASTICISMO | PARA BEATOS | 3| 150 | THEO |

| T22 | FUNDAMENTALISMO | PARA DESCUIDADOS | 3 | 90 | THEO |

| T33 | HEDONISMO | PARA SANOS | 3| 0 | THEO |

| T44 | COMUNISMO | PARA AVAROS | 6| 200 | THEO |

+-----+-----------------------+--------------------+------+---------+-------+
10 rows in set (0.00 sec)

mysql> select cnombre, ctarifa,ctarifa/cred AS TARIFA_POR_CREDITO

-> (ctarifa + 25)/cread AS TARIFA_MEDIA_POR_HORA

-> from curso where cdept = 'CIS';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
your

(MySQL :: ERROR 1064 AL CREAR UNA TABLA)

MySQL server version for the right syntax to use near '(ctarifa + 25)/cread AS
TARIFA_MEDIA_POR_HORA

from curso where cdept = 'CIS'' at line 2

mysql> Select ctarifa, SUM(cred) AS CREDITOS_TOTALES From curso

-> Group By ctarifa

-> Order By ctarifa DESC;

+---------+------------------+

| ctarifa | CREDITOS_TOTALES |

+---------+------------------+

| 200 | 9|

| 176 | 3|

| 150 | 3|

| 140 | 6|

| 100 | 9|

| 90 | 3|

| 50 | 6|

| 0| 15 |

+---------+------------------+

8 rows in set (0.06 sec)

mysql> Select cdept, AVG(ctarifa)


-> From curso

-> Group by cdept

-> HAVING AVG(ctarifa)> 100

-> AND Count (*) < 6;

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 '*) < 6' at line 5

mysql>

You might also like