MariaDB [produccion]> create table armada(armada int(11)auto_increment, codigo varchar(10)not null, cantidad int(11) not null, maquina varchar(10)not null, fecha Date, costo int(11)not null,observacion varchar(50)not null, foreign key(codigo) references producto(codigo)on delete cascade on update cascade, foreign key(maquina) references maquina(maquina)on delete cascade on update cascade); ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key MariaDB [produccion]> create table armada(armada int(11)primary key auto_increment, codigo varchar(10)not null, cantidad int(11) not null, maquina varchar(10)not null, fecha Date, costo int(11)not null,observacion varchar(50)not null, foreign key(codigo) references producto(codigo)on delete cascade on update cascade, foreign key(maquina) references maquina(maquina)on delete cascade on update cascade); ERROR 1005 (HY000): Can't create table `produccion`.`armada` (errno: 150 "Foreign key constraint is incorrectly formed") MariaDB [produccion]> create table maquina(maquina varchar(10)primary key not null, descripcion varchar(50)not null, a¤ocompra int(11) not null); Query OK, 0 rows affected (0.19 sec) MariaDB [produccion]> create table armada(armada int(11)primary key auto_increment, codigo varchar(10)not null, cantidad int(11) not null, maquina varchar(10)not null, fecha Date, costo int(11)not null,observacion varchar(50)not null, foreign key(codigo) references producto(codigo)on delete cascade on update cascade, foreign key(maquina) references maquina(maquina)on delete cascade on update cascade); Query OK, 0 rows affected (0.22 sec) MariaDB [produccion]> describe armada; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | varchar(50) | NO | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) MariaDB [produccion]> describe maquina; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | maquina | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | a¤ocompra | int(11) | NO | | NULL | | +-------------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) MariaDB [produccion]> create table operario(id_operario varchar(10)primary key not null, nombre varchar(30)not null, fecha_nac Date not null, rh varchar(5)not null); Query OK, 0 rows affected (0.17 sec) MariaDB [produccion]> create table turno(turno varchar(10)primary key not null, descripcion varchar(50)not null, extras boolean not null); Query OK, 0 rows affected (0.18 sec) MariaDB [produccion]> create table maquina operario(maquina varchar(10)not null, id_operario varchar(10)not null, foreign key(maquina) references maquina(maquina) on delete cascade on update cascade, foreign key(ip_operario) references operario(id_operario) on delete cascade on update cascade); 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 '(maquina varchar(10)not null, id_operario varchar(10)not null, foreign key(maqui' at line 1 MariaDB [produccion]> create table maquina_operario(maquina varchar(10)not null, id_operario varchar(10)not null, foreign key(maquina) references maquina(maquina) on delete cascade on update cascade, foreign key(ip_operario) references operario(id_operario) on delete cascade on update cascade); ERROR 1072 (42000): Key column 'ip_operario' doesn't exist in table MariaDB [produccion]> create table maquina_operario(maquina varchar(10)not null, id_operario varchar(10)not null, foreign key(maquina) references maquina(maquina) on delete cascade on update cascade, foreign key(id_operario) references operario(id_operario) on delete cascade on update cascade); Query OK, 0 rows affected (0.18 sec) MariaDB [produccion]> create table operario_turno(id_operario varchar(10)not null, turno varchar(10)not null, foreign key(id_operario) references operario(id_operario) on delete cascade on update cascade, foreign key(turno) references turno(turno) on delete cascade on update cascade); Query OK, 0 rows affected (0.20 sec) MariaDB [produccion]> describe operario -> ; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | id_operario | varchar(10) | NO | PRI | NULL | | | nombre | varchar(30) | NO | | NULL | | | fecha_nac | date | NO | | NULL | | | rh | varchar(5) | NO | | NULL | | +-------------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) MariaDB [produccion]> describe maquina_operario; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | maquina | varchar(10) | NO | MUL | NULL | | | id_operario | varchar(10) | NO | MUL | NULL | | +-------------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) MariaDB [produccion]> describe turno; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | turno | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | extras | tinyint(1) | NO | | NULL | | +-------------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) MariaDB [produccion]> describe operario_turno; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | id_operario | varchar(10) | NO | MUL | NULL | | | turno | varchar(10) | NO | MUL | NULL | | +-------------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) MariaDB [produccion]> show tables; +----------------------+ | Tables_in_produccion | +----------------------+ | armada | | compra | | maquina | | maquina_operario | | materiaprima | | mp_producto | | operario | | operario_turno | | producto | | turno | +----------------------+ 10 rows in set (0.00 sec) MariaDB [produccion]> describe materiaprima; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | codigo_mp | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | empaque | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | stock | decimal(4,1) | NO | | NULL | | +-------------+--------------+------+-----+---------+-------+ 5 rows in set (0.36 sec) MariaDB [produccion]> select * from compra -> ; +--------+-----------+----------+--------+------------+ | compra | codigo_mp | cantidad | costo | fecha | +--------+-----------+----------+--------+------------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | +--------+-----------+----------+--------+------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+ | compra | codigo_mp | cantidad | costo | fecha | +--------+-----------+----------+--------+------------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | +--------+-----------+----------+--------+------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> describe compra; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | compra | int(11) | NO | PRI | NULL | auto_increment | | codigo_mp | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | fecha | date | YES | | NULL | | +-----------+-------------+------+-----+---------+----------------+ 5 rows in set (0.03 sec) MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+ | compra | codigo_mp | cantidad | costo | fecha | +--------+-----------+----------+--------+------------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | +--------+-----------+----------+--------+------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> describe materiaprima; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | codigo_mp | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | empaque | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | stock | decimal(4,1) | NO | | NULL | | +-------------+--------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) MariaDB [produccion]> describe compra; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | compra | int(11) | NO | PRI | NULL | auto_increment | | codigo_mp | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | fecha | date | YES | | NULL | | +-----------+-------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec) MariaDB [produccion]> create procedure ingresaCompra(in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); 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 '(10),in cantidad(11),in costo(11), in fecha Date) begin insert into compra value' at line 1 MariaDB [produccion]> delimiter // MariaDB [produccion]> create procedure ingresaCompra(in compra(11,)in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); -> end -> // 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 '(11,)in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) begin insert ' at line 1 MariaDB [produccion]> delimiter ; MariaDB [produccion]> show procedure; 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 [produccion]> show procedure status; +----------------+-------------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation | +----------------+-------------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | almacenamiento | insertar_operario | PROCEDURE | root@localhost | 2019-05-26 12:41:20 | 2019-05-26 12:41:20 | DEFINER | | cp850 | cp850_general_ci | latin1_swedish_ci | +----------------+-------------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ 1 row in set (0.05 sec) MariaDB [produccion]> drop procedure insertar_operario; ERROR 1305 (42000): PROCEDURE produccion.insertar_operario does not exist MariaDB [produccion]> drop procedure insertar_operario; ERROR 1305 (42000): PROCEDURE produccion.insertar_operario does not exist MariaDB [produccion]> use almacenamiento; Database changed MariaDB [almacenamiento]> drop procedure insertar_operario; Query OK, 0 rows affected (0.02 sec) MariaDB [almacenamiento]> use produccion; Database changed MariaDB [produccion]> show procedure status; Empty set (0.01 sec) MariaDB [produccion]> delimiter // MariaDB [produccion]> create procedure ingresaCompra(in compra int(11),in codigo_mp varchar(10),in cantidad int(11),in costo int(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); -> end -> // Query OK, 0 rows affected (0.06 sec) MariaDB [produccion]> show procedure status; +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation | +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | produccion | ingresaCompra | PROCEDURE | root@localhost | 2019-10-30 09:40:58 | 2019-10-30 09:40:58 | DEFINER | | cp850 | cp850_general_ci | latin1_swedish_ci | +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ 1 row in set (0.01 sec) MariaDB [produccion]> create trigger caltotal before insert on compra -> for each row -> begin -> set new.total=new.cantidad*new.costo; -> end -> // Query OK, 0 rows affected (0.08 sec) MariaDB [produccion]> delimiter ; MariaDB [produccion]> delimiter // MariaDB [produccion]> create procedure ingresaCompra(in compra(11),in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); -> end -> // 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 '(11),in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) begin insert ' at line 1 MariaDB [produccion]> delimiter // MariaDB [produccion]> create procedure ingresaCompra(in codigo_mp(10),in cantidad(11),in costo(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); -> end -> // 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 '(10),in cantidad(11),in costo(11), in fecha Date) begin insert into compra value' at line 1 MariaDB [produccion]> delimiter // MariaDB [produccion]> create procedure ingresaCompra(in compra int(11),in codigo_mp varchar(10),in cantidad int(11),in costo int(11), in fecha Date) -> begin -> insert into compra values(0,codigo_mp,cantidad,costo,fecha); -> end -> // Query OK, 0 rows affected (0.06 sec) MariaDB [produccion]> delimiter ; MariaDB [produccion]> show procedure status; +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation | +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ | produccion | ingresaCompra | PROCEDURE | root@localhost | 2019-10-30 09:40:58 | 2019-10-30 09:40:58 | DEFINER | | cp850 | cp850_general_ci | latin1_swedish_ci | +------------+---------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+ 1 row in set (0.01 sec) MariaDB [produccion]> call ingresaCompra (0,90010450,80,125000,'201/10/28'); Query OK, 1 row affected (0.06 sec) MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+ | compra | codigo_mp | cantidad | costo | fecha | +--------+-----------+----------+--------+------------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | | 16 | 90010450 | 80 | 125000 | 0201-10-28 | +--------+-----------+----------+--------+------------+ 16 rows in set (0.00 sec) MariaDB [produccion]> SELECt * from operario; +-------------+---------------+------------+----+ | id_operario | nombre | fecha_nac | rh | +-------------+---------------+------------+----+ | 1036498562 | ANDRES RUA | 1986-06-02 | A+ | | 1036595636 | NELSON LOPERA | 1968-11-16 | O- | | 1146436052 | LUIS ARIAS | 1979-08-26 | O+ | | 1147891254 | ISAAC CARO | 1984-06-25 | O- | | 21406452 | FELIPE MENDEZ | 1980-04-11 | A- | | 28368489 | ROBIN CARDONA | 1979-08-30 | O+ | | 32875456 | JUAN LOPEZ | 1990-11-01 | H- | | 41589654 | ALBEIRO ROA | 1983-12-14 | O+ | +-------------+---------------+------------+----+ 8 rows in set (0.00 sec) MariaDB [produccion]> select * from operarios where year(current_date()) - year(fecha_nac) > 35; ERROR 1146 (42S02): Table 'produccion.operarios' doesn't exist MariaDB [produccion]> select * from operario where year(current_date()) - year(fecha_nac) > 35; +-------------+---------------+------------+----+ | id_operario | nombre | fecha_nac | rh | +-------------+---------------+------------+----+ | 1036595636 | NELSON LOPERA | 1968-11-16 | O- | | 1146436052 | LUIS ARIAS | 1979-08-26 | O+ | | 21406452 | FELIPE MENDEZ | 1980-04-11 | A- | | 28368489 | ROBIN CARDONA | 1979-08-30 | O+ | | 41589654 | ALBEIRO ROA | 1983-12-14 | O+ | +-------------+---------------+------------+----+ 5 rows in set (0.05 sec) MariaDB [produccion]> select * from operario; +-------------+---------------+------------+----+ | id_operario | nombre | fecha_nac | rh | +-------------+---------------+------------+----+ | 1036498562 | ANDRES RUA | 1986-06-02 | A+ | | 1036595636 | NELSON LOPERA | 1968-11-16 | O- | | 1146436052 | LUIS ARIAS | 1979-08-26 | O+ | | 1147891254 | ISAAC CARO | 1984-06-25 | O- | | 21406452 | FELIPE MENDEZ | 1980-04-11 | A- | | 28368489 | ROBIN CARDONA | 1979-08-30 | O+ | | 32875456 | JUAN LOPEZ | 1990-11-01 | H- | | 41589654 | ALBEIRO ROA | 1983-12-14 | O+ | +-------------+---------------+------------+----+ 8 rows in set (0.00 sec) MariaDB [produccion]> select * from operario where year(current_date()) - year(fecha_nac) > 35; +-------------+---------------+------------+----+ | id_operario | nombre | fecha_nac | rh | +-------------+---------------+------------+----+ | 1036595636 | NELSON LOPERA | 1968-11-16 | O- | | 1146436052 | LUIS ARIAS | 1979-08-26 | O+ | | 21406452 | FELIPE MENDEZ | 1980-04-11 | A- | | 28368489 | ROBIN CARDONA | 1979-08-30 | O+ | | 41589654 | ALBEIRO ROA | 1983-12-14 | O+ | +-------------+---------------+------------+----+ 5 rows in set (0.00 sec) MariaDB [produccion]> alter table compra add total int; Query OK, 0 rows affected (0.47 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [produccion]> describe compra; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | compra | int(11) | NO | PRI | NULL | auto_increment | | codigo_mp | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | fecha | date | YES | | NULL | | | total | int(11) | YES | | NULL | | +-----------+-------------+------+-----+---------+----------------+ 6 rows in set (0.04 sec) MariaDB [produccion]> alter table compra modify total int not null; Query OK, 16 rows affected, 16 warnings (0.58 sec) Records: 16 Duplicates: 0 Warnings: 16 MariaDB [produccion]> describe compra; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | compra | int(11) | NO | PRI | NULL | auto_increment | | codigo_mp | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | costo | int(11) | NO | | NULL | | | fecha | date | YES | | NULL | | | total | int(11) | NO | | NULL | | +-----------+-------------+------+-----+---------+----------------+ 6 rows in set (0.01 sec) MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+-------+ | compra | codigo_mp | cantidad | costo | fecha | total | +--------+-----------+----------+--------+------------+-------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | 0 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | 0 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | 0 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | 0 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | 0 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | 0 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | 0 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | 0 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | 0 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | 0 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | 0 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | 0 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | 0 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | 0 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | 0 | | 16 | 90010450 | 80 | 125000 | 0201-10-28 | 0 | +--------+-----------+----------+--------+------------+-------+ 16 rows in set (0.00 sec) MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before update on compra -> for each row -> begin -> set new.total=new.costo*new.cantidad; -> end -> // Query OK, 0 rows affected (0.14 sec) MariaDB [produccion]> delimiter ; MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+-------+ | compra | codigo_mp | cantidad | costo | fecha | total | +--------+-----------+----------+--------+------------+-------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | 0 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | 0 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | 0 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | 0 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | 0 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | 0 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | 0 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | 0 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | 0 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | 0 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | 0 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | 0 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | 0 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | 0 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | 0 | | 16 | 90010450 | 80 | 125000 | 0201-10-28 | 0 | +--------+-----------+----------+--------+------------+-------+ 16 rows in set (0.00 sec) MariaDB [produccion]> drop triggers caltotal; 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 'triggers caltotal' at line 1 MariaDB [produccion]> drop trigger caltotal; Query OK, 0 rows affected (0.00 sec) MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before insert on compra -> begin -> Ctrl-C -- exit! Bye C:\xampp\mysql\bin>mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 10.1.40-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)]> use produccion; Database changed MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before insert on compra -> for each row; -> begin -> set new.total=new.costo*new.cantidad; -> end -> // 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 '; begin set new.total=new.costo*new.cantidad; end' at line 2 MariaDB [produccion]> delimiter ; MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before insert on compra -> foe each row -> Ctrl-C -- exit! Bye C:\xampp\mysql\bin>mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.1.40-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)]> use produccion; Database changed MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before insert on compra -> for each row -> begin -> set total=new.costo*new.cantidad; -> end -> // ERROR 1193 (HY000): Unknown system variable 'total' MariaDB [produccion]> delimiter // MariaDB [produccion]> create trigger caltotal before insert on compra -> for each row -> begin -> set new.total=new.cantidad*new.costo; -> end -> // Query OK, 0 rows affected (0.08 sec) MariaDB [produccion]> delimiter ; MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+-------+ | compra | codigo_mp | cantidad | costo | fecha | total | +--------+-----------+----------+--------+------------+-------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | 0 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | 0 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | 0 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | 0 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | 0 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | 0 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | 0 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | 0 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | 0 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | 0 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | 0 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | 0 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | 0 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | 0 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | 0 | | 16 | 90010450 | 80 | 125000 | 0201-10-28 | 0 | +--------+-----------+----------+--------+------------+-------+ 16 rows in set (0.00 sec) MariaDB [produccion]> call ingresaCompra (0,90010550,40,250000,'2019/10/28'); ERROR 1136 (21S01): Column count doesn't match value count at row 1 MariaDB [produccion]> insert into compra values(0,'90010550',40,250000,'2019/10/28'); ERROR 1136 (21S01): Column count doesn't match value count at row 1 MariaDB [produccion]> insert into compra values(0,'90010550',40,250000,'2019/10/28',0); Query OK, 1 row affected (0.05 sec) MariaDB [produccion]> select * from compra; +--------+-----------+----------+--------+------------+----------+ | compra | codigo_mp | cantidad | costo | fecha | total | +--------+-----------+----------+--------+------------+----------+ | 1 | 90010450 | 200 | 120000 | 2019-09-01 | 0 | | 2 | 90010245 | 150 | 105000 | 2019-09-05 | 0 | | 3 | 90010625 | 80 | 80000 | 2019-09-11 | 0 | | 4 | 90010550 | 30 | 220000 | 2019-09-15 | 0 | | 5 | 90010245 | 50 | 110000 | 2019-09-26 | 0 | | 6 | 90010625 | 60 | 85000 | 2019-09-20 | 0 | | 7 | 90010450 | 100 | 130000 | 2019-09-30 | 0 | | 8 | 90010550 | 50 | 220000 | 2019-09-30 | 0 | | 9 | 90010450 | 120 | 125000 | 2019-10-02 | 0 | | 10 | 90010450 | 40 | 130000 | 2019-10-02 | 0 | | 11 | 90010550 | 60 | 220000 | 2019-10-02 | 0 | | 12 | 90010450 | 80 | 125000 | 2019-10-02 | 0 | | 13 | 90010550 | 50 | 220000 | 2019-10-08 | 0 | | 14 | 90010625 | 120 | 85000 | 2019-10-15 | 0 | | 15 | 90010245 | 60 | 110000 | 2019-10-15 | 0 | | 16 | 90010450 | 80 | 125000 | 0201-10-28 | 0 | | 17 | 90010550 | 40 | 250000 | 2019-10-28 | 10000000 | +--------+-----------+----------+--------+------------+----------+ 17 rows in set (0.00 sec) MariaDB [produccion]> select from compra where compra=17; 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 'from compra where compra=17' at line 1 MariaDB [produccion]> select from compra where compra='17'; 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 'from compra where compra='17'' at line 1 MariaDB [produccion]> select * from compra where compra='17'; +--------+-----------+----------+--------+------------+----------+ | compra | codigo_mp | cantidad | costo | fecha | total | +--------+-----------+----------+--------+------------+----------+ | 17 | 90010550 | 40 | 250000 | 2019-10-28 | 10000000 | +--------+-----------+----------+--------+------------+----------+ 1 row in set (0.02 sec) MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 7 rows in set (0.04 sec) MariaDB [produccion]> select armada,codigo,cantidad,observacion from armada where substr(codigo,5,3) in ('250'); Empty set (0.03 sec) MariaDB [produccion]> select armada,codigo,cantidad,observacion from armada where substr(codigo,4,3) in ('250'); Empty set (0.00 sec) MariaDB [produccion]> select armada,codigo,cantidad,observacion from armada where substr(codigo,4,3); +--------+----------+----------+-------------+ | armada | codigo | cantidad | observacion | +--------+----------+----------+-------------+ | 1 | 10400500 | 500 | | | 2 | 10400460 | 450 | limpio | | 3 | 10400250 | 350 | fumigado | | 4 | 10200460 | 750 | limpio | | 5 | 10200500 | 250 | limpio | | 6 | 10200250 | 350 | | | 7 | 10500500 | 450 | limpio | | 8 | 10500460 | 400 | limpio | | 9 | 10600500 | 400 | limpio | | 10 | 10400500 | 250 | fumigado | | 11 | 10400460 | 350 | limpio | | 12 | 10400250 | 550 | limpio | | 13 | 10600500 | 500 | fumigado | | 14 | 10500500 | 400 | limpio | | 15 | 10200500 | 450 | limpio | +--------+----------+----------+-------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> select armada,codigo,cantidad,observacion from armada where substr(codigo,6,3) in ('250'); +--------+----------+----------+-------------+ | armada | codigo | cantidad | observacion | +--------+----------+----------+-------------+ | 3 | 10400250 | 350 | fumigado | | 6 | 10200250 | 350 | | | 12 | 10400250 | 550 | limpio | +--------+----------+----------+-------------+ 3 rows in set (0.00 sec) MariaDB [produccion]> select * from armada; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 1 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | | | 2 | 10400460 | 450 | MAQ003 | 2019-09-05 | 0 | limpio | | 3 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 4 | 10200460 | 750 | MAQ003 | 2019-09-15 | 0 | limpio | | 5 | 10200500 | 250 | MAQ002 | 2019-09-26 | 0 | limpio | | 6 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | | | 7 | 10500500 | 450 | MAQ003 | 2019-09-30 | 0 | limpio | | 8 | 10500460 | 400 | MAQ003 | 2019-09-30 | 0 | limpio | | 9 | 10600500 | 400 | MAQ001 | 2019-10-02 | 0 | limpio | | 10 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 11 | 10400460 | 350 | MAQ002 | 2019-10-02 | 0 | limpio | | 12 | 10400250 | 550 | MAQ002 | 2019-10-02 | 0 | limpio | | 13 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | | 14 | 10500500 | 400 | MAQ001 | 2019-10-15 | 0 | limpio | | 15 | 10200500 | 450 | MAQ003 | 2019-10-15 | 0 | limpio | +--------+----------+----------+---------+------------+-------+-------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> update armada observacion='gorgojo' where armada='1'; 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 '='gorgojo' where armada='1'' at line 1 MariaDB [produccion]> delete from armada; Query OK, 15 rows affected (0.05 sec) MariaDB [produccion]> select * from armada; Empty set (0.00 sec) MariaDB [produccion]> insert into armada values('ARM0001','10400500',500,'MAQ001','2019/09/01',0,'gorgojo'); Query OK, 1 row affected, 1 warning (0.04 sec) MariaDB [produccion]> insert into armada values('ARM0002','10400460',450,'MAQ003','2019/09/05',0,'limpio'); Query OK, 1 row affected, 1 warning (0.04 sec) MariaDB [produccion]> insert into armada values('ARM0003','10400250',350,'MAQ002','2019/09/11',0,'fumigado'); Query OK, 1 row affected, 1 warning (0.12 sec) MariaDB [produccion]> insert into armada values('ARM0004','10200460',750,'MAQ003','2019/09/15',0,'limpio'); Query OK, 1 row affected, 1 warning (0.01 sec) MariaDB [produccion]> insert into armada values('ARM0005','10200500',250,'MAQ002','2019/09/26',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0006','10200250',350,'MAQ002','2019/09/20',0,'gorgojo'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0007','10500500',450,'MAQ003','2019/09/30',0,'limpio'); Query OK, 1 row affected, 1 warning (0.04 sec) MariaDB [produccion]> insert into armada values('ARM0008','10500460',400,'MAQ003','2019/09/30',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0009','10600500',400,'MAQ001','2019/10/02',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0010','10400500',250,'MAQ001','2019/10/02',0,'fumigado'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0011','10400460',350,'MAQ002','2019/10/02',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0012','10400250',550,'MAQ002','2019/10/02',0,'limpio'); Query OK, 1 row affected, 1 warning (0.04 sec) MariaDB [produccion]> insert into armada values('ARM0013','10600500',500,'MAQ001','2019/10/08',0,'fumigado'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0014','10500500',400,'MAQ001','2019/10/15',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> insert into armada values('ARM0015','10200500',450,'MAQ003','2019/10/15',0,'limpio'); Query OK, 1 row affected, 1 warning (0.02 sec) MariaDB [produccion]> select * from armada; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | | 17 | 10400460 | 450 | MAQ003 | 2019-09-05 | 0 | limpio | | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 19 | 10200460 | 750 | MAQ003 | 2019-09-15 | 0 | limpio | | 20 | 10200500 | 250 | MAQ002 | 2019-09-26 | 0 | limpio | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | | 22 | 10500500 | 450 | MAQ003 | 2019-09-30 | 0 | limpio | | 23 | 10500460 | 400 | MAQ003 | 2019-09-30 | 0 | limpio | | 24 | 10600500 | 400 | MAQ001 | 2019-10-02 | 0 | limpio | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 26 | 10400460 | 350 | MAQ002 | 2019-10-02 | 0 | limpio | | 27 | 10400250 | 550 | MAQ002 | 2019-10-02 | 0 | limpio | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | | 29 | 10500500 | 400 | MAQ001 | 2019-10-15 | 0 | limpio | | 30 | 10200500 | 450 | MAQ003 | 2019-10-15 | 0 | limpio | +--------+----------+----------+---------+------------+-------+-------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> select armada,codigo,cantidad,observacion from armada where substr(codigo,6,3) in ('250'); +--------+----------+----------+-------------+ | armada | codigo | cantidad | observacion | +--------+----------+----------+-------------+ | 18 | 10400250 | 350 | fumigado | | 21 | 10200250 | 350 | gorgojo | | 27 | 10400250 | 550 | limpio | +--------+----------+----------+-------------+ 3 rows in set (0.00 sec) MariaDB [produccion]> select * from materiaprima -> ; +-----------+------------------+---------+-------+-------+ | codigo_mp | descripcion | empaque | costo | stock | +-----------+------------------+---------+-------+-------+ | 90010245 | ARVEJA X 45KL | 45 | 0 | 52.5 | | 90010450 | LENTEJA X 50KL | 50 | 0 | 120.0 | | 90010550 | FRIJOL X 50KL | 50 | 0 | 60.2 | | 90010625 | MAZAMORRA X 25KL | 25 | 0 | 35.0 | +-----------+------------------+---------+-------+-------+ 4 rows in set (0.00 sec) MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 7 rows in set (0.01 sec) MariaDB [produccion]> select * from armada where observacion=2 and observacion='fumigado'; Empty set (0.03 sec) MariaDB [produccion]> select * from armada where observacion=2; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | +--------+----------+----------+---------+------------+-------+-------------+ 2 rows in set (0.00 sec) MariaDB [produccion]> select * from armada where observacion='fumigado'; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | +--------+----------+----------+---------+------------+-------+-------------+ 3 rows in set (0.01 sec) MariaDB [produccion]> select * from armada where observacion='fumigado' and observacion=2; Empty set (0.00 sec) MariaDB [produccion]> select * from armada where observacion='fumigado' or observacion=2; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | +--------+----------+----------+---------+------------+-------+-------------+ 5 rows in set (0.00 sec) MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 7 rows in set (0.01 sec) MariaDB [produccion]> select * from armada where observacion='fumigado' or observacion=2; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | +--------+----------+----------+---------+------------+-------+-------------+ 5 rows in set (0.00 sec) MariaDB [produccion]> select * from producto: -> ; 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 [produccion]> select * from producto; +----------+-----------------+---------+-------+ | codigo | descripcion | empaque | costo | +----------+-----------------+---------+-------+ | 10200250 | ARVEJA X 250 | 50 | 0 | | 10200460 | ARVEJA X 460 | 25 | 0 | | 10200500 | ARVEJA X 500 | 25 | 0 | | 10400250 | LENTEJA X 250 | 50 | 0 | | 10400460 | LENTEJA X 460 | 25 | 0 | | 10400500 | LENTEJA X 500 | 25 | 0 | | 10500460 | FRIJOL X 460 | 25 | 0 | | 10500500 | FRIJOL X 500 | 25 | 0 | | 10600500 | MAZAMORRA X 500 | 25 | 0 | +----------+-----------------+---------+-------+ 9 rows in set (0.03 sec) MariaDB [produccion]> select * from armada; +--------+----------+----------+---------+------------+-------+-------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | +--------+----------+----------+---------+------------+-------+-------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | | 17 | 10400460 | 450 | MAQ003 | 2019-09-05 | 0 | limpio | | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | | 19 | 10200460 | 750 | MAQ003 | 2019-09-15 | 0 | limpio | | 20 | 10200500 | 250 | MAQ002 | 2019-09-26 | 0 | limpio | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | | 22 | 10500500 | 450 | MAQ003 | 2019-09-30 | 0 | limpio | | 23 | 10500460 | 400 | MAQ003 | 2019-09-30 | 0 | limpio | | 24 | 10600500 | 400 | MAQ001 | 2019-10-02 | 0 | limpio | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | | 26 | 10400460 | 350 | MAQ002 | 2019-10-02 | 0 | limpio | | 27 | 10400250 | 550 | MAQ002 | 2019-10-02 | 0 | limpio | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | | 29 | 10500500 | 400 | MAQ001 | 2019-10-15 | 0 | limpio | | 30 | 10200500 | 450 | MAQ003 | 2019-10-15 | 0 | limpio | +--------+----------+----------+---------+------------+-------+-------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> alter table armada add descrip_maq varhar(20); 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 'varhar(20)' at line 1 MariaDB [produccion]> alter table armada add descrip_maq varchar(20); Query OK, 0 rows affected (0.77 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | | descrip_maq | varchar(20) | YES | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 8 rows in set (0.01 sec) MariaDB [produccion]> update armada -> join producto -> on armada.codigo=producto.codigo -> set armada.; 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 4 MariaDB [produccion]> alter table armada drop descrip_maq; Query OK, 0 rows affected (0.39 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [produccion]> describre armada; 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 'describre armada' at line 1 MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 7 rows in set (0.01 sec) MariaDB [produccion]> alter table armada add producto varchar(20); Query OK, 0 rows affected (0.54 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [produccion]> describe armada; +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | armada | int(11) | NO | PRI | NULL | auto_increment | | codigo | varchar(10) | NO | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | maquina | varchar(10) | NO | MUL | NULL | | | fecha | date | YES | | NULL | | | costo | int(11) | NO | | NULL | | | observacion | enum('limpio','gorgojo','fumigado') | NO | | NULL | | | producto | varchar(20) | YES | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ 8 rows in set (0.01 sec) MariaDB [produccion]> update armada -> join producto -> on armada.codigo=producto.codigo -> set armada.producto=producto.descripcion; Query OK, 15 rows affected (0.07 sec) Rows matched: 15 Changed: 15 Warnings: 0 MariaDB [produccion]> select * from armada; +--------+----------+----------+---------+------------+-------+-------------+-----------------+ | armada | codigo | cantidad | maquina | fecha | costo | observacion | producto | +--------+----------+----------+---------+------------+-------+-------------+-----------------+ | 16 | 10400500 | 500 | MAQ001 | 2019-09-01 | 0 | gorgojo | LENTEJA X 500 | | 17 | 10400460 | 450 | MAQ003 | 2019-09-05 | 0 | limpio | LENTEJA X 460 | | 18 | 10400250 | 350 | MAQ002 | 2019-09-11 | 0 | fumigado | LENTEJA X 250 | | 19 | 10200460 | 750 | MAQ003 | 2019-09-15 | 0 | limpio | ARVEJA X 460 | | 20 | 10200500 | 250 | MAQ002 | 2019-09-26 | 0 | limpio | ARVEJA X 500 | | 21 | 10200250 | 350 | MAQ002 | 2019-09-20 | 0 | gorgojo | ARVEJA X 250 | | 22 | 10500500 | 450 | MAQ003 | 2019-09-30 | 0 | limpio | FRIJOL X 500 | | 23 | 10500460 | 400 | MAQ003 | 2019-09-30 | 0 | limpio | FRIJOL X 460 | | 24 | 10600500 | 400 | MAQ001 | 2019-10-02 | 0 | limpio | MAZAMORRA X 500 | | 25 | 10400500 | 250 | MAQ001 | 2019-10-02 | 0 | fumigado | LENTEJA X 500 | | 26 | 10400460 | 350 | MAQ002 | 2019-10-02 | 0 | limpio | LENTEJA X 460 | | 27 | 10400250 | 550 | MAQ002 | 2019-10-02 | 0 | limpio | LENTEJA X 250 | | 28 | 10600500 | 500 | MAQ001 | 2019-10-08 | 0 | fumigado | MAZAMORRA X 500 | | 29 | 10500500 | 400 | MAQ001 | 2019-10-15 | 0 | limpio | FRIJOL X 500 | | 30 | 10200500 | 450 | MAQ003 | 2019-10-15 | 0 | limpio | ARVEJA X 500 | +--------+----------+----------+---------+------------+-------+-------------+-----------------+ 15 rows in set (0.00 sec) MariaDB [produccion]> select a.maquina,count(*) -> from maquina as m -> join maquina; ERROR 1054 (42S22): Unknown column 'a.maquina' in 'field list' MariaDB [produccion]> select a.nombre,count(*) -> from maquina as m -> join ; 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 3 MariaDB [produccion]> select a.nombre,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina -> group by a.nombre; ERROR 1054 (42S22): Unknown column 'a.nombre' in 'field list' MariaDB [produccion]> group by m.nombre; 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 'group by m.nombre' at line 1 MariaDB [produccion]> select a.nombre,count(*) -> ; ERROR 1109 (42S02): Unknown table 'a' in field list MariaDB [produccion]> select m.nombre,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina -> group by m.nombre; ERROR 1054 (42S22): Unknown column 'm.nombre' in 'field list' MariaDB [produccion]> select m.nombre,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina; ERROR 1054 (42S22): Unknown column 'm.nombre' in 'field list' MariaDB [produccion]> select a.nombre,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina; ERROR 1054 (42S22): Unknown column 'a.nombre' in 'field list' MariaDB [produccion]> describe maquina; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | maquina | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | añocompra | int(11) | NO | | NULL | | +-------------+-------------+------+-----+---------+-------+ 3 rows in set (0.04 sec) MariaDB [produccion]> select m.despcripcion,count(*) -> from maquina as m -> join armada as a -> group bu m.descripcion; 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 'bu m.descripcion' at line 4 MariaDB [produccion]> select m.despcripcion,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina -> group by m.descripcion; ERROR 1054 (42S22): Unknown column 'm.despcripcion' in 'field list' MariaDB [produccion]> select m.descripcion,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina -> group by m.descripcion; +-------------+----------+ | descripcion | count(*) | +-------------+----------+ | MAQUINA 1 | 5 | | MAQUINA 2 | 5 | | MAQUINA 3 | 5 | +-------------+----------+ 3 rows in set (0.04 sec) MariaDB [produccion]> create table armadaxmaquina -> select m.descripcion,count(*) -> from maquina as m -> join armada as a -> on m.maquina=a.maquina -> group by m.descripcion; Query OK, 3 rows affected (0.37 sec) Records: 3 Duplicates: 0 Warnings: 0 MariaDB [produccion]> describe armadaxmaquina; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | descripcion | varchar(50) | NO | | NULL | | | count(*) | bigint(21) | NO | | NULL | | +-------------+-------------+------+-----+---------+-------+ 2 rows in set (0.01 sec) MariaDB [produccion]> select * from armadaxmaquina; +-------------+----------+ | descripcion | count(*) | +-------------+----------+ | MAQUINA 1 | 5 | | MAQUINA 2 | 5 | | MAQUINA 3 | 5 | +-------------+----------+ 3 rows in set (0.00 sec)