Microsoft Windows [Versión 10.0.19044.2130] (c) Microsoft Corporation. Todos los derechos reservados. C:\Users\Harold Martinez>cd/xampp/mysql/bin C:\xampp\mysql\bin>mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 195 Server version: 10.4.24-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> source C:\xampp\ejer_subconsultas.sql Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Database changed Query OK, 0 rows affected (0.005 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.006 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.004 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.007 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.004 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.006 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.002 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.003 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.006 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) MariaDB [facturacion]> select * from cliente; Empty set (0.002 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(100,'alexandralopez','aranjuez','2003-12-03'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(200,'sebastianperez','sabaneta','2005-07-17'); Query OK, 1 row affected (0.002 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(300,'saraherrera','floresta','2007-09-20'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(400,'luisaroldan','floresta','2009-10-15'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(500,'mariohenao','bello','2004-02-28'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(600,'luisacifuentes','florencia','2003-09-01'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(700,'edithgarcia','envigado','2006-03-03'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(800,'claudialainez','itag','2005-04-13'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into cliente(cedula, nombre, direccion, fechainicio) values(900,'vivianpiedrahita','centro','2006-01-19'); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(1001,100,0,0,0,0); Query OK, 1 row affected (0.003 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(2002,300,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(3003,200,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(4004,400,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(5005,200,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(6006,500,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(7007,100,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(8008,400,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(9009,400,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(1101,600,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(2202,700,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(3303,600,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(4404,100,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(5505,700,0,0,0,0); Query OK, 1 row affected (0.002 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(6606,800,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(7707,900,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(8808,800,0,0,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into factura(nrofactura, cedula, subtotal, iva, retencion, total) values(9909,900,0,0,0,0); Query OK, 1 row affected (0.002 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('10','tv',1250000,22,0,0); Query OK, 1 row affected (0.004 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('20','auricules',75000,27,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('30','mp3',150000,24,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('40','mouse',25000,33,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('50','taclado',130000,45,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('60','discoduro',203000,17,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('70','unidaddvd',250000,19,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('80','usb',80000,28,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into producto(codigo, articulo, valorunitario, cantidad, valorventa, existencia) values('90','lapizoptico',134000,17,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(2,1001,'40',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(3,1001,'70',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(4,2002,'60',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(5,3003,'20',4,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(6,3003,'80',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(7,4004,'10',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(8,4004,'20',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(9,4004,'30',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(10,4004,'60',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(11,4004,'70',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(12,4004,'80',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(13,5005,'10',3,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(14,6006,'20',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(15,6006,'80',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(16,6006,'30',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(17,6006,'90',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(18,6006,'50',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(19,6006,'40',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(20,7007,'10',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(21,7007,'90',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(22,8008,'60',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(23,8008,'40',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(24,8008,'50',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(25,9009,'50',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(26,9009,'80',1,0,0); Query OK, 1 row affected (0.002 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(27,1101,'30',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(28,2202,'30',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(29,1101,'60',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(30,3303,'60',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(31,4404,'90',3,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(32,5505,'80',4,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(33,6606,'70',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(34,7707,'10',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(35,8808,'40',2,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(36,9909,'20',3,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(37,9909,'30',4,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(38,6606,'50',5,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(39,7707,'40',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> insert into detallefactura(id, nrofactura, codigo, cantidad, valor, total) values(40,1101,'30',1,0,0); Query OK, 1 row affected (0.001 sec) MariaDB [facturacion]> select * from cliente; +--------+------------------+-----------+-------------+ | cedula | nombre | direccion | fechainicio | +--------+------------------+-----------+-------------+ | 100 | alexandralopez | aranjuez | 2003-12-03 | | 200 | sebastianperez | sabaneta | 2005-07-17 | | 300 | saraherrera | floresta | 2007-09-20 | | 400 | luisaroldan | floresta | 2009-10-15 | | 500 | mariohenao | bello | 2004-02-28 | | 600 | luisacifuentes | florencia | 2003-09-01 | | 700 | edithgarcia | envigado | 2006-03-03 | | 800 | claudialainez | itag | 2005-04-13 | | 900 | vivianpiedrahita | centro | 2006-01-19 | +--------+------------------+-----------+-------------+ 9 rows in set (0.001 sec) MariaDB [facturacion]> select * from detallefactura; +------+------------+--------+----------+-------+-------+ | id | nrofactura | codigo | cantidad | valor | total | +------+------------+--------+----------+-------+-------+ | 0001 | 1001 | 10 | 1 | 0 | 0 | | 0002 | 1001 | 40 | 2 | 0 | 0 | | 0003 | 1001 | 70 | 1 | 0 | 0 | | 0004 | 2002 | 60 | 2 | 0 | 0 | | 0005 | 3003 | 20 | 4 | 0 | 0 | | 0006 | 3003 | 80 | 1 | 0 | 0 | | 0007 | 4004 | 10 | 2 | 0 | 0 | | 0008 | 4004 | 20 | 1 | 0 | 0 | | 0009 | 4004 | 30 | 1 | 0 | 0 | | 0010 | 4004 | 60 | 1 | 0 | 0 | | 0011 | 4004 | 70 | 1 | 0 | 0 | | 0012 | 4004 | 80 | 2 | 0 | 0 | | 0013 | 5005 | 10 | 3 | 0 | 0 | | 0014 | 6006 | 20 | 1 | 0 | 0 | | 0015 | 6006 | 80 | 2 | 0 | 0 | | 0016 | 6006 | 30 | 2 | 0 | 0 | | 0017 | 6006 | 90 | 2 | 0 | 0 | | 0018 | 6006 | 50 | 1 | 0 | 0 | | 0019 | 6006 | 40 | 2 | 0 | 0 | | 0020 | 7007 | 10 | 1 | 0 | 0 | | 0021 | 7007 | 90 | 2 | 0 | 0 | | 0022 | 8008 | 60 | 2 | 0 | 0 | | 0023 | 8008 | 40 | 2 | 0 | 0 | | 0024 | 8008 | 50 | 1 | 0 | 0 | | 0025 | 9009 | 50 | 2 | 0 | 0 | | 0026 | 9009 | 80 | 1 | 0 | 0 | | 0027 | 1101 | 30 | 1 | 0 | 0 | | 0028 | 2202 | 30 | 2 | 0 | 0 | | 0029 | 1101 | 60 | 1 | 0 | 0 | | 0030 | 3303 | 60 | 2 | 0 | 0 | | 0031 | 4404 | 90 | 3 | 0 | 0 | | 0032 | 5505 | 80 | 4 | 0 | 0 | | 0033 | 6606 | 70 | 2 | 0 | 0 | | 0034 | 7707 | 10 | 1 | 0 | 0 | | 0035 | 8808 | 40 | 2 | 0 | 0 | | 0036 | 9909 | 20 | 3 | 0 | 0 | | 0037 | 9909 | 30 | 4 | 0 | 0 | | 0038 | 6606 | 50 | 5 | 0 | 0 | | 0039 | 7707 | 40 | 1 | 0 | 0 | | 0040 | 1101 | 30 | 1 | 0 | 0 | +------+------------+--------+----------+-------+-------+ 40 rows in set (0.000 sec) MariaDB [facturacion]> select * from factura; +------------+--------+----------+-----+-----------+-------+ | nrofactura | cedula | subtotal | iva | retencion | total | +------------+--------+----------+-----+-----------+-------+ | 1001 | 100 | 0 | 0 | 0 | 0 | | 1101 | 600 | 0 | 0 | 0 | 0 | | 2002 | 300 | 0 | 0 | 0 | 0 | | 2202 | 700 | 0 | 0 | 0 | 0 | | 3003 | 200 | 0 | 0 | 0 | 0 | | 3303 | 600 | 0 | 0 | 0 | 0 | | 4004 | 400 | 0 | 0 | 0 | 0 | | 4404 | 100 | 0 | 0 | 0 | 0 | | 5005 | 200 | 0 | 0 | 0 | 0 | | 5505 | 700 | 0 | 0 | 0 | 0 | | 6006 | 500 | 0 | 0 | 0 | 0 | | 6606 | 800 | 0 | 0 | 0 | 0 | | 7007 | 100 | 0 | 0 | 0 | 0 | | 7707 | 900 | 0 | 0 | 0 | 0 | | 8008 | 400 | 0 | 0 | 0 | 0 | | 8808 | 800 | 0 | 0 | 0 | 0 | | 9009 | 400 | 0 | 0 | 0 | 0 | | 9909 | 900 | 0 | 0 | 0 | 0 | +------------+--------+----------+-----+-----------+-------+ 18 rows in set (0.000 sec) MariaDB [facturacion]> select * from producto; +--------+-------------+---------------+----------+------------+------------+ | codigo | articulo | valorunitario | cantidad | valorventa | existencia | +--------+-------------+---------------+----------+------------+------------+ | 10 | tv | 1250000 | 22 | 0 | 0 | | 20 | auricules | 75000 | 27 | 0 | 0 | | 30 | mp3 | 150000 | 24 | 0 | 0 | | 40 | mouse | 25000 | 33 | 0 | 0 | | 50 | taclado | 130000 | 45 | 0 | 0 | | 60 | discoduro | 203000 | 17 | 0 | 0 | | 70 | unidaddvd | 250000 | 19 | 0 | 0 | | 80 | usb | 80000 | 28 | 0 | 0 | | 90 | lapizoptico | 134000 | 17 | 0 | 0 | +--------+-------------+---------------+----------+------------+------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> Update producto set valorventa = (valorunitario * 0.17) + valorunitario; Query OK, 9 rows affected (0.002 sec) Rows matched: 9 Changed: 9 Warnings: 0 MariaDB [facturacion]> select * from producto; +--------+-------------+---------------+----------+------------+------------+ | codigo | articulo | valorunitario | cantidad | valorventa | existencia | +--------+-------------+---------------+----------+------------+------------+ | 10 | tv | 1250000 | 22 | 1462500 | 0 | | 20 | auricules | 75000 | 27 | 87750 | 0 | | 30 | mp3 | 150000 | 24 | 175500 | 0 | | 40 | mouse | 25000 | 33 | 29250 | 0 | | 50 | taclado | 130000 | 45 | 152100 | 0 | | 60 | discoduro | 203000 | 17 | 237510 | 0 | | 70 | unidaddvd | 250000 | 19 | 292500 | 0 | | 80 | usb | 80000 | 28 | 93600 | 0 | | 90 | lapizoptico | 134000 | 17 | 156780 | 0 | +--------+-------------+---------------+----------+------------+------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> Update detallefactura set valor = (select valorventa from producto where codigo = detallefactura.codigo); Query OK, 40 rows affected (0.002 sec) Rows matched: 40 Changed: 40 Warnings: 0 MariaDB [facturacion]> select * from detallefactura; +------+------------+--------+----------+---------+-------+ | id | nrofactura | codigo | cantidad | valor | total | +------+------------+--------+----------+---------+-------+ | 0001 | 1001 | 10 | 1 | 1462500 | 0 | | 0002 | 1001 | 40 | 2 | 29250 | 0 | | 0003 | 1001 | 70 | 1 | 292500 | 0 | | 0004 | 2002 | 60 | 2 | 237510 | 0 | | 0005 | 3003 | 20 | 4 | 87750 | 0 | | 0006 | 3003 | 80 | 1 | 93600 | 0 | | 0007 | 4004 | 10 | 2 | 1462500 | 0 | | 0008 | 4004 | 20 | 1 | 87750 | 0 | | 0009 | 4004 | 30 | 1 | 175500 | 0 | | 0010 | 4004 | 60 | 1 | 237510 | 0 | | 0011 | 4004 | 70 | 1 | 292500 | 0 | | 0012 | 4004 | 80 | 2 | 93600 | 0 | | 0013 | 5005 | 10 | 3 | 1462500 | 0 | | 0014 | 6006 | 20 | 1 | 87750 | 0 | | 0015 | 6006 | 80 | 2 | 93600 | 0 | | 0016 | 6006 | 30 | 2 | 175500 | 0 | | 0017 | 6006 | 90 | 2 | 156780 | 0 | | 0018 | 6006 | 50 | 1 | 152100 | 0 | | 0019 | 6006 | 40 | 2 | 29250 | 0 | | 0020 | 7007 | 10 | 1 | 1462500 | 0 | | 0021 | 7007 | 90 | 2 | 156780 | 0 | | 0022 | 8008 | 60 | 2 | 237510 | 0 | | 0023 | 8008 | 40 | 2 | 29250 | 0 | | 0024 | 8008 | 50 | 1 | 152100 | 0 | | 0025 | 9009 | 50 | 2 | 152100 | 0 | | 0026 | 9009 | 80 | 1 | 93600 | 0 | | 0027 | 1101 | 30 | 1 | 175500 | 0 | | 0028 | 2202 | 30 | 2 | 175500 | 0 | | 0029 | 1101 | 60 | 1 | 237510 | 0 | | 0030 | 3303 | 60 | 2 | 237510 | 0 | | 0031 | 4404 | 90 | 3 | 156780 | 0 | | 0032 | 5505 | 80 | 4 | 93600 | 0 | | 0033 | 6606 | 70 | 2 | 292500 | 0 | | 0034 | 7707 | 10 | 1 | 1462500 | 0 | | 0035 | 8808 | 40 | 2 | 29250 | 0 | | 0036 | 9909 | 20 | 3 | 87750 | 0 | | 0037 | 9909 | 30 | 4 | 175500 | 0 | | 0038 | 6606 | 50 | 5 | 152100 | 0 | | 0039 | 7707 | 40 | 1 | 29250 | 0 | | 0040 | 1101 | 30 | 1 | 175500 | 0 | +------+------------+--------+----------+---------+-------+ 40 rows in set (0.000 sec) MariaDB [facturacion]> Update detallefactura set total = cantidad * valor; Query OK, 40 rows affected (0.002 sec) Rows matched: 40 Changed: 40 Warnings: 0 MariaDB [facturacion]> select * from detallefactura; +------+------------+--------+----------+---------+---------+ | id | nrofactura | codigo | cantidad | valor | total | +------+------------+--------+----------+---------+---------+ | 0001 | 1001 | 10 | 1 | 1462500 | 1462500 | | 0002 | 1001 | 40 | 2 | 29250 | 58500 | | 0003 | 1001 | 70 | 1 | 292500 | 292500 | | 0004 | 2002 | 60 | 2 | 237510 | 475020 | | 0005 | 3003 | 20 | 4 | 87750 | 351000 | | 0006 | 3003 | 80 | 1 | 93600 | 93600 | | 0007 | 4004 | 10 | 2 | 1462500 | 2925000 | | 0008 | 4004 | 20 | 1 | 87750 | 87750 | | 0009 | 4004 | 30 | 1 | 175500 | 175500 | | 0010 | 4004 | 60 | 1 | 237510 | 237510 | | 0011 | 4004 | 70 | 1 | 292500 | 292500 | | 0012 | 4004 | 80 | 2 | 93600 | 187200 | | 0013 | 5005 | 10 | 3 | 1462500 | 4387500 | | 0014 | 6006 | 20 | 1 | 87750 | 87750 | | 0015 | 6006 | 80 | 2 | 93600 | 187200 | | 0016 | 6006 | 30 | 2 | 175500 | 351000 | | 0017 | 6006 | 90 | 2 | 156780 | 313560 | | 0018 | 6006 | 50 | 1 | 152100 | 152100 | | 0019 | 6006 | 40 | 2 | 29250 | 58500 | | 0020 | 7007 | 10 | 1 | 1462500 | 1462500 | | 0021 | 7007 | 90 | 2 | 156780 | 313560 | | 0022 | 8008 | 60 | 2 | 237510 | 475020 | | 0023 | 8008 | 40 | 2 | 29250 | 58500 | | 0024 | 8008 | 50 | 1 | 152100 | 152100 | | 0025 | 9009 | 50 | 2 | 152100 | 304200 | | 0026 | 9009 | 80 | 1 | 93600 | 93600 | | 0027 | 1101 | 30 | 1 | 175500 | 175500 | | 0028 | 2202 | 30 | 2 | 175500 | 351000 | | 0029 | 1101 | 60 | 1 | 237510 | 237510 | | 0030 | 3303 | 60 | 2 | 237510 | 475020 | | 0031 | 4404 | 90 | 3 | 156780 | 470340 | | 0032 | 5505 | 80 | 4 | 93600 | 374400 | | 0033 | 6606 | 70 | 2 | 292500 | 585000 | | 0034 | 7707 | 10 | 1 | 1462500 | 1462500 | | 0035 | 8808 | 40 | 2 | 29250 | 58500 | | 0036 | 9909 | 20 | 3 | 87750 | 263250 | | 0037 | 9909 | 30 | 4 | 175500 | 702000 | | 0038 | 6606 | 50 | 5 | 152100 | 760500 | | 0039 | 7707 | 40 | 1 | 29250 | 29250 | | 0040 | 1101 | 30 | 1 | 175500 | 175500 | +------+------------+--------+----------+---------+---------+ 40 rows in set (0.000 sec) MariaDB [facturacion]> Update factura set subtotal = (select sum(total) from detallefactura where nrofactura = factura.nrofactura); Query OK, 18 rows affected (0.002 sec) Rows matched: 18 Changed: 18 Warnings: 0 MariaDB [facturacion]> select * from factura; +------------+--------+----------+-----+-----------+-------+ | nrofactura | cedula | subtotal | iva | retencion | total | +------------+--------+----------+-----+-----------+-------+ | 1001 | 100 | 1813500 | 0 | 0 | 0 | | 1101 | 600 | 588510 | 0 | 0 | 0 | | 2002 | 300 | 475020 | 0 | 0 | 0 | | 2202 | 700 | 351000 | 0 | 0 | 0 | | 3003 | 200 | 444600 | 0 | 0 | 0 | | 3303 | 600 | 475020 | 0 | 0 | 0 | | 4004 | 400 | 3905460 | 0 | 0 | 0 | | 4404 | 100 | 470340 | 0 | 0 | 0 | | 5005 | 200 | 4387500 | 0 | 0 | 0 | | 5505 | 700 | 374400 | 0 | 0 | 0 | | 6006 | 500 | 1150110 | 0 | 0 | 0 | | 6606 | 800 | 1345500 | 0 | 0 | 0 | | 7007 | 100 | 1776060 | 0 | 0 | 0 | | 7707 | 900 | 1491750 | 0 | 0 | 0 | | 8008 | 400 | 685620 | 0 | 0 | 0 | | 8808 | 800 | 58500 | 0 | 0 | 0 | | 9009 | 400 | 397800 | 0 | 0 | 0 | | 9909 | 900 | 965250 | 0 | 0 | 0 | +------------+--------+----------+-----+-----------+-------+ 18 rows in set (0.000 sec) MariaDB [facturacion]> Update factura set iva = subtotal * 0.16; Query OK, 18 rows affected (0.002 sec) Rows matched: 18 Changed: 18 Warnings: 0 MariaDB [facturacion]> Update factura set retencion = subtotal * 0.035; Query OK, 18 rows affected (0.001 sec) Rows matched: 18 Changed: 18 Warnings: 0 MariaDB [facturacion]> Update factura set total = subtotal + iva - retencion; Query OK, 18 rows affected (0.001 sec) Rows matched: 18 Changed: 18 Warnings: 0 MariaDB [facturacion]> select * from factura; +------------+--------+----------+--------+-----------+---------+ | nrofactura | cedula | subtotal | iva | retencion | total | +------------+--------+----------+--------+-----------+---------+ | 1001 | 100 | 1813500 | 290160 | 63473 | 2040187 | | 1101 | 600 | 588510 | 94162 | 20598 | 662074 | | 2002 | 300 | 475020 | 76003 | 16626 | 534397 | | 2202 | 700 | 351000 | 56160 | 12285 | 394875 | | 3003 | 200 | 444600 | 71136 | 15561 | 500175 | | 3303 | 600 | 475020 | 76003 | 16626 | 534397 | | 4004 | 400 | 3905460 | 624874 | 136691 | 4393643 | | 4404 | 100 | 470340 | 75254 | 16462 | 529132 | | 5005 | 200 | 4387500 | 702000 | 153563 | 4935937 | | 5505 | 700 | 374400 | 59904 | 13104 | 421200 | | 6006 | 500 | 1150110 | 184018 | 40254 | 1293874 | | 6606 | 800 | 1345500 | 215280 | 47093 | 1513687 | | 7007 | 100 | 1776060 | 284170 | 62162 | 1998068 | | 7707 | 900 | 1491750 | 238680 | 52211 | 1678219 | | 8008 | 400 | 685620 | 109699 | 23997 | 771322 | | 8808 | 800 | 58500 | 9360 | 2048 | 65812 | | 9009 | 400 | 397800 | 63648 | 13923 | 447525 | | 9909 | 900 | 965250 | 154440 | 33784 | 1085906 | +------------+--------+----------+--------+-----------+---------+ 18 rows in set (0.000 sec) MariaDB [facturacion]> Update producto set existencia = cantidad - (select sum(cantidad) from detallefactura where codigo = producto.codigo); Query OK, 9 rows affected (0.001 sec) Rows matched: 9 Changed: 9 Warnings: 0 MariaDB [facturacion]> select * from producto; +--------+-------------+---------------+----------+------------+------------+ | codigo | articulo | valorunitario | cantidad | valorventa | existencia | +--------+-------------+---------------+----------+------------+------------+ | 10 | tv | 1250000 | 22 | 1462500 | 14 | | 20 | auricules | 75000 | 27 | 87750 | 18 | | 30 | mp3 | 150000 | 24 | 175500 | 13 | | 40 | mouse | 25000 | 33 | 29250 | 24 | | 50 | taclado | 130000 | 45 | 152100 | 36 | | 60 | discoduro | 203000 | 17 | 237510 | 9 | | 70 | unidaddvd | 250000 | 19 | 292500 | 15 | | 80 | usb | 80000 | 28 | 93600 | 18 | | 90 | lapizoptico | 134000 | 17 | 156780 | 10 | +--------+-------------+---------------+----------+------------+------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> select * from cliente; +--------+------------------+-----------+-------------+ | cedula | nombre | direccion | fechainicio | +--------+------------------+-----------+-------------+ | 100 | alexandralopez | aranjuez | 2003-12-03 | | 200 | sebastianperez | sabaneta | 2005-07-17 | | 300 | saraherrera | floresta | 2007-09-20 | | 400 | luisaroldan | floresta | 2009-10-15 | | 500 | mariohenao | bello | 2004-02-28 | | 600 | luisacifuentes | florencia | 2003-09-01 | | 700 | edithgarcia | envigado | 2006-03-03 | | 800 | claudialainez | itag | 2005-04-13 | | 900 | vivianpiedrahita | centro | 2006-01-19 | +--------+------------------+-----------+-------------+ 9 rows in set (0.001 sec) MariaDB [facturacion]> select factura ,sum(total) as 'total compra por cliente’ from cliente group by nombre; ERROR 1054 (42S22): Unknown column 'factura' in 'field list' MariaDB [facturacion]> select cedula ,sum(total) as 'total compra por cliente’ from factura group by cedula; +--------+--------------------------+ | cedula | total compra por cliente | +--------+--------------------------+ | 100 | 4567387 | | 200 | 5436112 | | 300 | 534397 | | 400 | 5612490 | | 500 | 1293874 | | 600 | 1196471 | | 700 | 816075 | | 800 | 1579499 | | 900 | 2764125 | +--------+--------------------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> select codigo ,sum(total) as 'total venta por producto from detallefactura group by codigo; '> ' -> ; ERROR 1054 (42S22): Unknown column 'codigo' in 'field list' MariaDB [facturacion]> select codigo ,sum(total) as 'total venta por producto from detallefactura’ group by codigo; ERROR 1054 (42S22): Unknown column 'codigo' in 'field list' MariaDB [facturacion]> select codigo ,sum(total) as 'total venta por producto’ from detallefactura group by codigo; +--------+--------------------------+ | codigo | total venta por producto | +--------+--------------------------+ | 10 | 11700000 | | 20 | 789750 | | 30 | 1930500 | | 40 | 263250 | | 50 | 1368900 | | 60 | 1900080 | | 70 | 1170000 | | 80 | 936000 | | 90 | 1097460 | +--------+--------------------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> Select nrofactura,cedula,total from factura where cedula = 100; +------------+--------+---------+ | nrofactura | cedula | total | +------------+--------+---------+ | 1001 | 100 | 2040187 | | 4404 | 100 | 529132 | | 7007 | 100 | 1998068 | +------------+--------+---------+ 3 rows in set (0.001 sec) MariaDB [facturacion]> create table detallado(id int(5) not null auto_increment,       -> cedula varchar(10) not null,      -> nrofactura int(20) not null,      -> totalarticulos int(20) not null, -> valortotal int(20) not null, -> PRIMARY KEY (id)); Query OK, 0 rows affected (0.007 sec) MariaDB [facturacion]> describe detallado; +----------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+----------------+ | id | int(5) | NO | PRI | NULL | auto_increment | | cedula | varchar(10) | NO | | NULL | | | nrofactura | int(20) | NO | | NULL | | | totalarticulos | int(20) | NO | | NULL | | | valortotal | int(20) | NO | | NULL | | +----------------+-------------+------+-----+---------+----------------+ 5 rows in set (0.003 sec) MariaDB [facturacion]> Create table clientetotal like cliente; Query OK, 0 rows affected (0.008 sec) MariaDB [facturacion]> Alter table clientetotal add nrofacturas int(10) not null; Query OK, 0 rows affected (0.006 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> Alter table clientetotal add sumaarticulos int(10) not null; Query OK, 0 rows affected (0.004 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> Alter table clientetotal add totalpagado int(10) not null -> ; Query OK, 0 rows affected (0.005 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> select * from clientetotal; Empty set (0.000 sec) MariaDB [facturacion]> Insert into clientetotal select * from cliente; ERROR 1136 (21S01): Column count doesn't match value count at row 1 MariaDB [facturacion]> show tables; +-----------------------+ | Tables_in_facturacion | +-----------------------+ | cliente | | clientetotal | | detallado | | detallefactura | | factura | | producto | +-----------------------+ 6 rows in set (0.001 sec) MariaDB [facturacion]> drop table clientetotal; Query OK, 0 rows affected (0.004 sec) MariaDB [facturacion]> show tables; +-----------------------+ | Tables_in_facturacion | +-----------------------+ | cliente | | detallado | | detallefactura | | factura | | producto | +-----------------------+ 5 rows in set (0.000 sec) MariaDB [facturacion]> Create table clientetotal like cliente; Query OK, 0 rows affected (0.006 sec) MariaDB [facturacion]> Insert into clientetotal select * from cliente; Query OK, 9 rows affected (0.002 sec) Records: 9 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> Alter table clientetotal add nrofacturas int(10) not null; Query OK, 0 rows affected (0.004 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> Alter table clientetotal add sumaarticulos int(10) not null; Query OK, 0 rows affected (0.004 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> Alter table clientetotal add totalpagado int(10) not null; Query OK, 0 rows affected (0.004 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [facturacion]> select * from clientetotal; +--------+------------------+-----------+-------------+-------------+---------------+-------------+ | cedula | nombre | direccion | fechainicio | nrofacturas | sumaarticulos | totalpagado | +--------+------------------+-----------+-------------+-------------+---------------+-------------+ | 100 | alexandralopez | aranjuez | 2003-12-03 | 0 | 0 | 0 | | 200 | sebastianperez | sabaneta | 2005-07-17 | 0 | 0 | 0 | | 300 | saraherrera | floresta | 2007-09-20 | 0 | 0 | 0 | | 400 | luisaroldan | floresta | 2009-10-15 | 0 | 0 | 0 | | 500 | mariohenao | bello | 2004-02-28 | 0 | 0 | 0 | | 600 | luisacifuentes | florencia | 2003-09-01 | 0 | 0 | 0 | | 700 | edithgarcia | envigado | 2006-03-03 | 0 | 0 | 0 | | 800 | claudialainez | itag | 2005-04-13 | 0 | 0 | 0 | | 900 | vivianpiedrahita | centro | 2006-01-19 | 0 | 0 | 0 | +--------+------------------+-----------+-------------+-------------+---------------+-------------+ 9 rows in set (0.000 sec) MariaDB [facturacion]> select ceudla from cliente where fechainicio<2004; ERROR 1054 (42S22): Unknown column 'ceudla' in 'field list' MariaDB [facturacion]> select cedula from cliente where fechainicio<2004); 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 ')' at line 1 MariaDB [facturacion]> select cedula from cliente where fechainicio<2004; Empty set, 1 warning (0.000 sec) MariaDB [facturacion]> select cedula from cliente where fechainicio<2004-01-01; Empty set, 1 warning (0.000 sec) MariaDB [facturacion]> select cedula from cliente where fechainicio<’2004-01-01’; +--------+ | cedula | +--------+ | 100 | | 600 | +--------+ 2 rows in set (0.000 sec) MariaDB [facturacion]> delete from factura where cedula = (select cedula from cliente where fechainicio<’2004-01-01’); ERROR 1242 (21000): Subquery returns more than 1 row MariaDB [facturacion]> describe cliente; +-------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+-------+ | cedula | int(10) | NO | PRI | NULL | | | nombre | char(40) | NO | | NULL | | | direccion | char(30) | NO | | NULL | | | fechainicio | date | NO | | NULL | | +-------------+----------+------+-----+---------+-------+ 4 rows in set (0.002 sec) MariaDB [facturacion]> describe factura; +------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------+------+-----+---------+-------+ | nrofactura | int(4) | NO | PRI | NULL | | | cedula | int(10) | NO | MUL | NULL | | | subtotal | int(20) | NO | | NULL | | | iva | int(20) | NO | | NULL | | | retencion | int(20) | NO | | NULL | | | total | int(20) | NO | | NULL | | +------------+---------+------+-----+---------+-------+ 6 rows in set (0.002 sec) MariaDB [facturacion]> select cliente.cedula, cliente.nombre, factura.cedula from cliente left join factura on cliente.cedula=factura.cedula where factura.cedula is null; Empty set (0.000 sec) MariaDB [facturacion]> exit Bye C:\xampp\mysql\bin>mysqldump -B -uroot -p facturacion>c:/xampp/facturacion.sql Enter password: C:\xampp\mysql\bin>