mysql> Insert into cliente(cedula,nombre,direcci¢n,fechainicio) values(?100?,?Alexandra Lopez?,?Aranjuez?,?2003-12-03?); 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 '?100?,?Alexandra Lopez?,?Aranjuez?,?2003-12-03?)' at line 1 mysql> 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.02 sec) mysql> Insert into cliente(cedula,nombre,direcci¢n,fechainicio) values(?100?,?Alexandra Lopez?,?Aranjuez?,?2003-12-03?); 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 '?100?,?Alexandra Lopez?,?Aranjuez?,?2003-12-03?)' at line 1 mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values(100,?Alexandra Lopez?,?Aranjuez?,?2003-12-03?); 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 '?Alexandra Lopez?,?Aranjuez?,?2003-12-03?)' at line 1 mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('100','Alexandra Lopez','Aranjuez','2003-12-03'); Query OK, 1 row affected (0.05 sec) mysql> select * from cliente; +--------+-----------------+-----------+-------------+ | cedula | nombre | direccion | fechainicio | +--------+-----------------+-----------+-------------+ | 100 | Alexandra Lopez | Aranjuez | 2003-12-03 | +--------+-----------------+-----------+-------------+ 1 row in set (0.00 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('200','Sebastian Perez','Sabaneta','2005-07-17'); Query OK, 1 row affected (0.06 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('300','Sara Herrera','Floresta','2007-09-20'); Query OK, 1 row affected (0.05 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('400','Luisa Roldan','Floresta','2009-10-15'); Query OK, 1 row affected (0.05 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('500','Mario Henao','Bello','2004-02-28'); Query OK, 1 row affected (0.03 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('600','Luisa Cifuentes','Florencia','2003-09-01'); Query OK, 1 row affected (0.05 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('700','Edith Garcia','Envigado','2006-03-03'); Query OK, 1 row affected (0.03 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('800','Claudia Lainez','Itagui','2005-04-13'); Query OK, 1 row affected (0.06 sec) mysql> Insert into cliente(cedula,nombre,direccion,fechainicio) values('900','Vivian Piedrahita','Centro','2006-01-19'); Query OK, 1 row affected (0.03 sec) mysql> describe detallefactura; +------------+--------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------------------+------+-----+---------+----------------+ | id | int(4) unsigned zerofill | NO | PRI | NULL | auto_increment | | nrofactura | int(4) | NO | MUL | NULL | | | codigo | char(10) | NO | MUL | NULL | | | cantidad | int(4) | NO | | NULL | | | valor | int(15) | NO | | NULL | | | total | int(15) | NO | | NULL | | +------------+--------------------------+------+-----+---------+----------------+ 6 rows in set (0.03 sec) mysql> mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values ('1','1001','10','1','0','0'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`facturacion`.`detallefactura`, CONSTRAINT `detallefactura_ibfk_1` FOREIGN KEY (`nrofactura`) REFERENCES `factura` (`nrofactura`) ON DELETE CASCADE ON UPDATE CASCADE) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (1,1001,'10',1,0,0); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`facturacion`.`detallefactura`, CONSTRAINT `detallefactura_ibfk_1` FOREIGN KEY (`nrofactura`) REFERENCES `factura` (`nrofactura`) ON DELETE CASCADE ON UPDATE CASCADE) mysql> insert into DETALLEFACTURA(id,nrofactura,codigo,cantidad,valor,total) values('1','1001','10',1,0,0); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`facturacion`.`detallefactura`, CONSTRAINT `detallefactura_ibfk_1` FOREIGN KEY (`nrofactura`) REFERENCES `factura` (`nrofactura`) ON DELETE CASCADE ON UPDATE CASCADE) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values('1','1001','10',1,0,0); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`facturacion`.`detallefactura`, CONSTRAINT `detallefactura_ibfk_1` FOREIGN KEY (`nrofactura`) REFERENCES `factura` (`nrofactura`) ON DELETE CASCADE ON UPDATE CASCADE) mysql> 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.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (1001,100,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> show tables; +-----------------------+ | Tables_in_facturacion | +-----------------------+ | cliente | | detallefactura | | factura | | producto | +-----------------------+ 4 rows in set (0.00 sec) mysql> select * from factura; +------------+--------+----------+-----+-----------+-------+ | nrofactura | cedula | subtotal | iva | retencion | total | +------------+--------+----------+-----+-----------+-------+ | 1001 | 100 | 0 | 0 | 0 | 0 | +------------+--------+----------+-----+-----------+-------+ 1 row in set (0.00 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (2002,300,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (3003,200,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (4004,400,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (5005,200,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (6006,500,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (7007,100,0,0,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (8008,400,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (9009,400,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (1101,600,0,0,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (2202,700,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (3303,600,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (4404,100,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (5505,700,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (6606,800,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (7707,900,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (8808,800,0,0,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into factura(nrofactura,cedula,subtotal,iva,retencion,total) values (9909,900,0,0,0,0); Query OK, 1 row affected (0.02 sec) mysql> describe producto; +---------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | PRI | NULL | | | articulo | char(20) | NO | | NULL | | | valorunitario | int(20) | NO | | NULL | | | cantidad | int(4) | NO | | NULL | | | valorventa | int(20) | NO | | NULL | | | existencia | int(4) | NO | | NULL | | +---------------+----------+------+-----+---------+-------+ 6 rows in set (0.01 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('10','tv',22,0,0); ERROR 1136 (21S01): Column count doesn't match value count at row 1 mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('10','tv',1250000,22,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('20','Auriculares',75000,27,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('30','Mp3',150000,24,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('40','Mouse',25000,33,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('50','Teclado',130000,45,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('60','Disco Duro',203000,17,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('70','Unidad de dvd',250000,19,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('80','Usb',80000,28,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into producto(codigo,articulo,valorunitario,cantidad,valorventa,existencia) values ('90','Lapiz Optico',134000,17,0,0); Query OK, 1 row affected (0.03 sec) mysql> select * from producto; +--------+---------------+---------------+----------+------------+------------+ | codigo | articulo | valorunitario | cantidad | valorventa | existencia | +--------+---------------+---------------+----------+------------+------------+ | 10 | tv | 1250000 | 22 | 0 | 0 | | 20 | Auriculares | 75000 | 27 | 0 | 0 | | 30 | Mp3 | 150000 | 24 | 0 | 0 | | 40 | Mouse | 25000 | 33 | 0 | 0 | | 50 | Teclado | 130000 | 45 | 0 | 0 | | 60 | Disco Duro | 203000 | 17 | 0 | 0 | | 70 | Unidad de dvd | 250000 | 19 | 0 | 0 | | 80 | Usb | 80000 | 28 | 0 | 0 | | 90 | Lapiz Optico | 134000 | 17 | 0 | 0 | +--------+---------------+---------------+----------+------------+------------+ 9 rows in set (0.00 sec) mysql> describe detallefactura; +------------+--------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------------------+------+-----+---------+----------------+ | id | int(4) unsigned zerofill | NO | PRI | NULL | auto_increment | | nrofactura | int(4) | NO | MUL | NULL | | | codigo | char(10) | NO | MUL | NULL | | | cantidad | int(4) | NO | | NULL | | | valor | int(15) | NO | | NULL | | | total | int(15) | NO | | NULL | | +------------+--------------------------+------+-----+---------+----------------+ 6 rows in set (0.01 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (1,1001,'10',1,0,0); Query OK, 1 row affected (0.03 sec) mysql> select * from detallefactura; +------+------------+--------+----------+-------+-------+ | id | nrofactura | codigo | cantidad | valor | total | +------+------------+--------+----------+-------+-------+ | 0001 | 1001 | 10 | 1 | 0 | 0 | +------+------------+--------+----------+-------+-------+ 1 row in set (0.00 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (2,1001,'40',2,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (3,1001,'70',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (4,2002,'60',2,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (5,3003,'20',4,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (6,3003,'80',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (7,4004,'10',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (8,4004,'20',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (9,4004,'30',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (10,4004,'60',1,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (11,4004,'70',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (12,4004,'80',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (13,5005,'10',3,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (14,6006,'20',1,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (15,6006,'80',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (16,6006,'30',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (17,6006,'90',2,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (18,6006,'50',1,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (19,6006,'40',2,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (20,7007,'10',1,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (21,7007,'90',2,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (22,8008,'60',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (23,8008,'40',2,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (24,8008,'50',1,0,0); Query OK, 1 row affected (0.01 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (25,9009,'50',2,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (26,9009,'80',1,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (27,1101,'30',1,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (28,2202,'30',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (29,1101,'60',1,0,0); Query OK, 1 row affected (0.05 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (30,3303,'60',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (31,4404,'90',3,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (32,5505,'80',4,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (33,6606,'70',2,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (34,7707,'10',1,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (35,8808,'40',2,0,0); Query OK, 1 row affected (0.02 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (36,9909,'20',3,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (37,9909,'30',4,0,0); Query OK, 1 row affected (0.04 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (38,6606,'50',5,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (39,7707,'40',1,0,0); Query OK, 1 row affected (0.03 sec) mysql> insert into detallefactura(id,nrofactura,codigo,cantidad,valor,total) values (40,1101,'30',1,0,0); Query OK, 1 row affected (0.03 sec) mysql> 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.00 sec) mysql> show tables; +-----------------------+ | Tables_in_facturacion | +-----------------------+ | cliente | | detallefactura | | factura | | producto | +-----------------------+ 4 rows in set (0.00 sec) mysql> Update producto set valorventa=(select valorunitario +(valorunitario*0.17) ); Query OK, 9 rows affected (0.06 sec) Rows matched: 9 Changed: 9 Warnings: 0 mysql> update detallefactura set valor=(select valorventa from producto where producto.codigo=detallefactura.codigo); Query OK, 40 rows affected (0.05 sec) Rows matched: 40 Changed: 40 Warnings: 0 mysql> Update detallefactura set total=(cantidad*valor); Query OK, 40 rows affected (0.03 sec) Rows matched: 40 Changed: 40 Warnings: 0 mysql> select *from detallefatura; ERROR 1146 (42S02): Table 'facturacion.detallefatura' doesn't exist mysql> 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.00 sec) mysql> Update factura set iva=(subtotal*0.16); Query OK, 0 rows affected (0.04 sec) Rows matched: 18 Changed: 0 Warnings: 0 mysql> Update factura set retencion=(subtotal*0.035); Query OK, 0 rows affected (0.04 sec) Rows matched: 18 Changed: 0 Warnings: 0 mysql> Update factura set total=((subtotal +iva)-retencion); Query OK, 0 rows affected (0.04 sec) Rows matched: 18 Changed: 0 Warnings: 0 mysql> 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.00 sec) mysql> Update producto set existencia=cantidad-(select sum(cantidad) from detallefactura where detallefactura.codigo=producto.codigo); Query OK, 9 rows affected (0.03 sec) Rows matched: 9 Changed: 9 Warnings: 0 mysql> select* from detalle factura; ERROR 1146 (42S02): Table 'facturacion.detalle' doesn't exist mysql> 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.00 sec) mysql> select * from producto; +--------+---------------+---------------+----------+------------+------------+ | codigo | articulo | valorunitario | cantidad | valorventa | existencia | +--------+---------------+---------------+----------+------------+------------+ | 10 | tv | 1250000 | 22 | 1462500 | 14 | | 20 | Auriculares | 75000 | 27 | 87750 | 18 | | 30 | Mp3 | 150000 | 24 | 175500 | 13 | | 40 | Mouse | 25000 | 33 | 29250 | 24 | | 50 | Teclado | 130000 | 45 | 152100 | 36 | | 60 | Disco Duro | 203000 | 17 | 237510 | 9 | | 70 | Unidad de dvd | 250000 | 19 | 292500 | 15 | | 80 | Usb | 80000 | 28 | 93600 | 18 | | 90 | Lapiz Optico | 134000 | 17 | 156780 | 10 | +--------+---------------+---------------+----------+------------+------------+ 9 rows in set (0.00 sec) mysql> Select nombre, count(nombre) as facturas from factura,cliente where factura.cedula=cliente.cedula group by nombre; +-------------------+----------+ | nombre | facturas | +-------------------+----------+ | Alexandra Lopez | 3 | | Claudia Lainez | 2 | | Edith Garcia | 2 | | Luisa Cifuentes | 2 | | Luisa Roldan | 3 | | Mario Henao | 1 | | Sara Herrera | 1 | | Sebastian Perez | 2 | | Vivian Piedrahita | 2 | +-------------------+----------+ 9 rows in set (0.05 sec) mysql> select articulo, sum(total) as 'total de ventas' from detallefactura,producto where detallefactura.codigo=producto.codigo group by articulo; +---------------+-----------------+ | articulo | total de ventas | +---------------+-----------------+ | Auriculares | 789750 | | Disco Duro | 1900080 | | Lapiz Optico | 1097460 | | Mouse | 263250 | | Mp3 | 1930500 | | Teclado | 1368900 | | tv | 11700000 | | Unidad de dvd | 1170000 | | Usb | 936000 | +---------------+-----------------+ 9 rows in set (0.00 sec) mysql> select cedula,nrofactura,total from factura where factura.cedula=(select cedula from cliente where nombre='alexanda lopez'); Empty set (0.01 sec) mysql> select cedula,nrofactura,total from factura where factura.cedula=(select cedula from cliente where nombre='alexandra lopez'); +--------+------------+-------+ | cedula | nrofactura | total | +--------+------------+-------+ | 100 | 1001 | 0 | | 100 | 4404 | 0 | | 100 | 7007 | 0 | +--------+------------+-------+ 3 rows in set (0.00 sec) mysql> create table detallado (id int(15) not null primary key, cedula int(10)not null,nrofactura int(6) not null,totalarticulos(6) not null,valortotal int (15) not null); 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) not null,valortotal int (15) not null)' at line 1 mysql> create table detallado (id int(15) not null primary key, cedula int(10)not null,nrofactura int(6) not null,totalarticulos int(6) not null,valortotal int (15) not null); Query OK, 0 rows affected (0.24 sec) mysql> describe tabla detallado; ERROR 1146 (42S02): Table 'facturacion.tabla' doesn't exist mysql> describe datallado; ERROR 1146 (42S02): Table 'facturacion.datallado' doesn't exist mysql> describe detallado; +----------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------+------+-----+---------+-------+ | id | int(15) | NO | PRI | NULL | | | cedula | int(10) | NO | | NULL | | | nrofactura | int(6) | NO | | NULL | | | totalarticulos | int(6) | NO | | NULL | | | valortotal | int(15) | NO | | NULL | | +----------------+---------+------+-----+---------+-------+ 5 rows in set (0.02 sec) mysql> delete from detallado where cedula=(select cedula from cliente where year(fechainicio)<2004 and detallado.cedula=cliente.cedula); Query OK, 0 rows affected (0.00 sec) mysql> select * from detallado; Empty set (0.00 sec) mysql> exit