MariaDB [libreria]> show tables; +--------------------+ | Tables_in_libreria | +--------------------+ | autor | | editorial | | liautedi | | libro | | materia | +--------------------+ 5 rows in set (0.002 sec) MariaDB [libreria]> describelibro; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'describelibro' at line 1 MariaDB [libreria]> describe libro; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | id_libro | varchar(10) | NO | PRI | NULL | | | Titulo | varchar(60) | NO | | NULL | | | Numpg | float | NO | | NULL | | | Precio | float | NO | | NULL | | | codigmat1 | varchar(10) | NO | MUL | NULL | | +-----------+-------------+------+-----+---------+-------+ 5 rows in set (0.014 sec) MariaDB [libreria]> select count(*) from libro; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061) ERROR: Can't connect to the server unknown [libreria]> select count(*) from libro; No connection. Trying to reconnect... ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061) ERROR: Can't connect to the server unknown [libreria]> select count(*) from libro; No connection. Trying to reconnect... Connection id: 8 Current database: libreria +----------+ | count(*) | +----------+ | 7 | +----------+ 1 row in set (0.005 sec) MariaDB [libreria]> select * from libro; +----------+---------------------+-------+--------+-----------+ | id_libro | Titulo | Numpg | Precio | codigmat1 | +----------+---------------------+-------+--------+-----------+ | L01 | C lculo II | 120 | 55000 | M01 | | L02 | Bd II | 150 | 65000 | M09 | | L03 | Estructura de Datos | 180 | 85000 | M03 | | L04 | Ingl‚s | 280 | 105000 | M04 | | L05 | Admon en una p gina | 70 | 7500 | M05 | | L06 | Contabiloidad I | 170 | 27500 | M06 | | L07 | Redes | 370 | 32500 | M07 | +----------+---------------------+-------+--------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> select count(*)'Cantidad de libros' from libro; +--------------------+ | Cantidad de libros | +--------------------+ | 7 | +--------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> select * from libro; +----------+---------------------+-------+--------+-----------+ | id_libro | Titulo | Numpg | Precio | codigmat1 | +----------+---------------------+-------+--------+-----------+ | L01 | C lculo II | 120 | 55000 | M01 | | L02 | Bd II | 150 | 65000 | M09 | | L03 | Estructura de Datos | 180 | 85000 | M03 | | L04 | Ingl‚s | 280 | 105000 | M04 | | L05 | Admon en una p gina | 70 | 7500 | M05 | | L06 | Contabiloidad I | 170 | 27500 | M06 | | L07 | Redes | 370 | 32500 | M07 | +----------+---------------------+-------+--------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> select sum( precio)'Valor total' from libro; +-------------+ | Valor total | +-------------+ | 377500 | +-------------+ 1 row in set (0.001 sec) MariaDB [libreria]> select max( precio)'El libro mas caro es:' from libro; +-----------------------+ | El libro mas caro es: | +-----------------------+ | 105000 | +-----------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> select mim( numpg)'Numero de paginas minimo:' from libro; ERROR 1305 (42000): FUNCTION libreria.mim does not exist MariaDB [libreria]> select min( numpg)'Numero de paginas minimo:' from libro; +---------------------------+ | Numero de paginas minimo: | +---------------------------+ | 70 | +---------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> select titulo, min( numpg)'Numero de paginas minimo:' from libro; +------------+---------------------------+ | titulo | Numero de paginas minimo: | +------------+---------------------------+ | C lculo II | 70 | +------------+---------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> select avg(precio)'Valor promedio de un libro' from libro; +----------------------------+ | Valor promedio de un libro | +----------------------------+ | 53928.57142857143 | +----------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> update libro set titulo='Redes y Comunicaciones' where id_libro='l07'; Query OK, 1 row affected (0.011 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+--------+-----------+ | id_libro | Titulo | Numpg | Precio | codigmat1 | +----------+------------------------+-------+--------+-----------+ | L01 | C lculo II | 120 | 55000 | M01 | | L02 | Bd II | 150 | 65000 | M09 | | L03 | Estructura de Datos | 180 | 85000 | M03 | | L04 | Ingl‚s | 280 | 105000 | M04 | | L05 | Admon en una p gina | 70 | 7500 | M05 | | L06 | Contabiloidad I | 170 | 27500 | M06 | | L07 | Redes y Comunicaciones | 370 | 32500 | M07 | +----------+------------------------+-------+--------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> update libro set titulo='Contabilidad I' where id_libro='l06'; Query OK, 1 row affected (0.016 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+--------+-----------+ | id_libro | Titulo | Numpg | Precio | codigmat1 | +----------+------------------------+-------+--------+-----------+ | L01 | C lculo II | 120 | 55000 | M01 | | L02 | Bd II | 150 | 65000 | M09 | | L03 | Estructura de Datos | 180 | 85000 | M03 | | L04 | Ingl‚s | 280 | 105000 | M04 | | L05 | Admon en una p gina | 70 | 7500 | M05 | | L06 | Contabilidad I | 170 | 27500 | M06 | | L07 | Redes y Comunicaciones | 370 | 32500 | M07 | +----------+------------------------+-------+--------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> alter table libro add cantidad int not null after numpg; Query OK, 0 rows affected (0.067 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [libreria]> alter table libro add vtotal float not null after precio; Query OK, 0 rows affected (0.023 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+----------+--------+--------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+------------------------+-------+----------+--------+--------+-----------+ | L01 | C lculo II | 120 | 0 | 55000 | 0 | M01 | | L02 | Bd II | 150 | 0 | 65000 | 0 | M09 | | L03 | Estructura de Datos | 180 | 0 | 85000 | 0 | M03 | | L04 | Ingl‚s | 280 | 0 | 105000 | 0 | M04 | | L05 | Admon en una p gina | 70 | 0 | 7500 | 0 | M05 | | L06 | Contabilidad I | 170 | 0 | 27500 | 0 | M06 | | L07 | Redes y Comunicaciones | 370 | 0 | 32500 | 0 | M07 | +----------+------------------------+-------+----------+--------+--------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> update libro set Cantidad=5 where id_libro='l01'; Query OK, 1 row affected (0.017 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+----------+--------+--------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+------------------------+-------+----------+--------+--------+-----------+ | L01 | C lculo II | 120 | 5 | 55000 | 0 | M01 | | L02 | Bd II | 150 | 0 | 65000 | 0 | M09 | | L03 | Estructura de Datos | 180 | 0 | 85000 | 0 | M03 | | L04 | Ingl‚s | 280 | 0 | 105000 | 0 | M04 | | L05 | Admon en una p gina | 70 | 0 | 7500 | 0 | M05 | | L06 | Contabilidad I | 170 | 0 | 27500 | 0 | M06 | | L07 | Redes y Comunicaciones | 370 | 0 | 32500 | 0 | M07 | +----------+------------------------+-------+----------+--------+--------+-----------+ 7 rows in set (0.000 sec) MariaDB [libreria]> update libro set Cantidad=10 where id_libro='l02'; Query OK, 1 row affected (0.016 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> update libro set Cantidad=15 where id_libro='l03'; Query OK, 1 row affected (0.016 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> update libro set Cantidad=20 where id_libro='l04'; Query OK, 1 row affected (0.061 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> update libro set Cantidad=25 where id_libro='l05'; Query OK, 1 row affected (0.018 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> update libro set Cantidad=30 where id_libro='l06'; Query OK, 1 row affected (0.012 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> update libro set Cantidad=35 where id_libro='l07'; Query OK, 1 row affected (0.017 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+----------+--------+--------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+------------------------+-------+----------+--------+--------+-----------+ | L01 | C lculo II | 120 | 5 | 55000 | 0 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 0 | M09 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 0 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 0 | M04 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 0 | M05 | | L06 | Contabilidad I | 170 | 30 | 27500 | 0 | M06 | | L07 | Redes y Comunicaciones | 370 | 35 | 32500 | 0 | M07 | +----------+------------------------+-------+----------+--------+--------+-----------+ 7 rows in set (0.000 sec) MariaDB [libreria]> update libro set vtotal=cantidad*precio; Query OK, 7 rows affected (0.011 sec) Rows matched: 7 Changed: 7 Warnings: 0 MariaDB [libreria]> select * from libro; +----------+------------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+------------------------+-------+----------+--------+---------+-----------+ | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L07 | Redes y Comunicaciones | 370 | 35 | 32500 | 1137500 | M07 | +----------+------------------------+-------+----------+--------+---------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> delete from libro where id_libro='lo7'; Query OK, 0 rows affected (0.001 sec) MariaDB [libreria]> select * from libro; +----------+------------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+------------------------+-------+----------+--------+---------+-----------+ | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L07 | Redes y Comunicaciones | 370 | 35 | 32500 | 1137500 | M07 | +----------+------------------------+-------+----------+--------+---------+-----------+ 7 rows in set (0.001 sec) MariaDB [libreria]> delete from libro where id_libro='l07'; Query OK, 1 row affected (0.022 sec) MariaDB [libreria]> select * from libro; +----------+---------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+---------------------+-------+----------+--------+---------+-----------+ | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | +----------+---------------------+-------+----------+--------+---------+-----------+ 6 rows in set (0.001 sec) MariaDB [libreria]> select * from libro order by titulo; +----------+---------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+---------------------+-------+----------+--------+---------+-----------+ | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | +----------+---------------------+-------+----------+--------+---------+-----------+ 6 rows in set (0.001 sec) MariaDB [libreria]> select * from libro order by titulo desc; +----------+---------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+---------------------+-------+----------+--------+---------+-----------+ | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | +----------+---------------------+-------+----------+--------+---------+-----------+ 6 rows in set (0.001 sec) MariaDB [libreria]> select * from libro order by numpg asc; +----------+---------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+---------------------+-------+----------+--------+---------+-----------+ | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | +----------+---------------------+-------+----------+--------+---------+-----------+ 6 rows in set (0.001 sec) MariaDB [libreria]> select * from libro order by numpg desc; +----------+---------------------+-------+----------+--------+---------+-----------+ | id_libro | Titulo | Numpg | cantidad | Precio | vtotal | codigmat1 | +----------+---------------------+-------+----------+--------+---------+-----------+ | L04 | Ingl‚s | 280 | 20 | 105000 | 2100000 | M04 | | L03 | Estructura de Datos | 180 | 15 | 85000 | 1275000 | M03 | | L06 | Contabilidad I | 170 | 30 | 27500 | 825000 | M06 | | L02 | Bd II | 150 | 10 | 65000 | 650000 | M09 | | L01 | C lculo II | 120 | 5 | 55000 | 275000 | M01 | | L05 | Admon en una p gina | 70 | 25 | 7500 | 187500 | M05 | +----------+---------------------+-------+----------+--------+---------+-----------+ 6 rows in set (0.001 sec) MariaDB [libreria]> describe libro; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | id_libro | varchar(10) | NO | PRI | NULL | | | Titulo | varchar(60) | NO | | NULL | | | Numpg | float | NO | | NULL | | | cantidad | int(11) | NO | | NULL | | | Precio | float | NO | | NULL | | | vtotal | float | NO | | NULL | | | codigmat1 | varchar(10) | NO | MUL | NULL | | +-----------+-------------+------+-----+---------+-------+ 7 rows in set (0.007 sec) MariaDB [libreria]> describe liuatedi; ERROR 1146 (42S02): Table 'libreria.liuatedi' doesn't exist MariaDB [libreria]> describe liautedi; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | id_libro1 | varchar(10) | NO | MUL | NULL | | | codaut1 | varchar(10) | NO | MUL | NULL | | | codedit1 | varchar(10) | NO | MUL | NULL | | +-----------+-------------+------+-----+---------+-------+ 3 rows in set (0.011 sec) MariaDB [libreria]> describe autor; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | codaut | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(20) | NO | | NULL | | +--------+-------------+------+-----+---------+-------+ 2 rows in set (0.013 sec) MariaDB [libreria]> select libro.id_libro,libro.titulo,autor.docaut,autor.nombre from libro inner join liautedi on libro.id_libro=liautedi.id_libro1 inner join autor on liautedi.codaut1=autor.codaut; ERROR 1054 (42S22): Unknown column 'autor.docaut' in 'field list' MariaDB [libreria]> select libro.id_libro,libro.titulo,autor.codaut,autor.nombre from libro inner join liautedi on libro.id_libro=liautedi.id_libro1 inner join autor on liautedi.codaut1=autor.codaut; +----------+----------------+--------+---------------------+ | id_libro | titulo | codaut | nombre | +----------+----------------+--------+---------------------+ | L02 | Bd II | A01 | Luis Joyanes | | L02 | Bd II | A05 | Robert Lorber | | L06 | Contabilidad I | A02 | Jorge Vaquez Posada | | L04 | Ingl‚s | A04 | Riaz Khadem | | L04 | Ingl‚s | A04 | Riaz Khadem | | L04 | Ingl‚s | A04 | Riaz Khadem | +----------+----------------+--------+---------------------+ 6 rows in set (0.006 sec) MariaDB [libreria]> select distinct libro.id_libro,libro.titulo,autor.codaut,autor.nombre from libro inner join liautedi on libro.id_libro=liautedi.id_libro1 inner join autor on liautedi.codaut1=autor.codaut; +----------+----------------+--------+---------------------+ | id_libro | titulo | codaut | nombre | +----------+----------------+--------+---------------------+ | L02 | Bd II | A01 | Luis Joyanes | | L02 | Bd II | A05 | Robert Lorber | | L06 | Contabilidad I | A02 | Jorge Vaquez Posada | | L04 | Ingl‚s | A04 | Riaz Khadem | +----------+----------------+--------+---------------------+ 4 rows in set (0.009 sec) MariaDB [libreria]> exit