MariaDB [(none)]> CREATE DATABASE SanCarDB; Query OK, 1 row affected (0.001 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | bd_biblioteca | | information_schema | | libreria | | matricula2 | | mysql | | performance_schema | | phpmyadmin | | reto2 | | sancardb | | sistema_escolar | | sistemaventa | | test | +--------------------+ 12 rows in set (0.001 sec) MariaDB [(none)]> use sancardb; Database changed MariaDB [sancardb]> show tables; Empty set (0.001 sec) MariaDB [sancardb]> CREATE TABLE Clientes ( -> cliente_id INT AUTO_INCREMENT PRIMARY KEY, -> nombre VARCHAR(50) NOT NULL, -> apellido VARCHAR(50) NOT NULL, -> telefono VARCHAR(15), -> correo VARCHAR(100), -> fecha_registro DATE NOT NULL -> ); Query OK, 0 rows affected (0.007 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | +--------------------+ 1 row in set (0.001 sec) MariaDB [sancardb]> describe clientes; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | cliente_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(50) | NO | | NULL | | | apellido | varchar(50) | NO | | NULL | | | telefono | varchar(15) | YES | | NULL | | | correo | varchar(100) | YES | | NULL | | | fecha_registro | date | NO | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 6 rows in set (0.014 sec) MariaDB [sancardb]> CREATE TABLE Direccion ( -> direccion_id INT AUTO_INCREMENT PRIMARY KEY, -> cliente_id INT, -> calle VARCHAR(100), -> ciudad VARCHAR(50), -> estado VARCHAR(50), -> codigo_postal VARCHAR(10), -> FOREIGN KEY (cliente_id) REFERENCES Clientes(cliente_id) -> ); Query OK, 0 rows affected (0.027 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | direccion | +--------------------+ 2 rows in set (0.001 sec) MariaDB [sancardb]> describe direccion; +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | direccion_id | int(11) | NO | PRI | NULL | auto_increment | | cliente_id | int(11) | YES | MUL | NULL | | | calle | varchar(100) | YES | | NULL | | | ciudad | varchar(50) | YES | | NULL | | | estado | varchar(50) | YES | | NULL | | | codigo_postal | varchar(10) | YES | | NULL | | +---------------+--------------+------+-----+---------+----------------+ 6 rows in set (0.013 sec) MariaDB [sancardb]> CREATE TABLE Productos ( -> producto_id INT AUTO_INCREMENT PRIMARY KEY, -> nombre VARCHAR(100) NOT NULL, -> descripcion TEXT, -> precio DECIMAL(10, 2) NOT NULL, -> stock INT NOT NULL -> ); Query OK, 0 rows affected (0.007 sec) MariaDB [sancardb]> describe productos; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | producto_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(100) | NO | | NULL | | | descripcion | text | YES | | NULL | | | precio | decimal(10,2) | NO | | NULL | | | stock | int(11) | NO | | NULL | | +-------------+---------------+------+-----+---------+----------------+ 5 rows in set (0.012 sec) MariaDB [sancardb]> CREATE TABLE Proveedor ( -> proveedor_id INT AUTO_INCREMENT PRIMARY KEY, -> nombre VARCHAR(100) NOT NULL, -> telefono VARCHAR(15), -> direccion VARCHAR(150) -> ); Query OK, 0 rows affected (0.007 sec) MariaDB [sancardb]> describe proveedor; +--------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+----------------+ | proveedor_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(100) | NO | | NULL | | | telefono | varchar(15) | YES | | NULL | | | direccion | varchar(150) | YES | | NULL | | +--------------+--------------+------+-----+---------+----------------+ 4 rows in set (0.011 sec) MariaDB [sancardb]> CREATE TABLE Usuarios ( -> usuario_id INT AUTO_INCREMENT PRIMARY KEY, -> nombre VARCHAR(50) NOT NULL, -> rol VARCHAR(50) NOT NULL, -> email VARCHAR(100) UNIQUE, -> password VARCHAR(100) NOT NULL -> ); Query OK, 0 rows affected (0.020 sec) MariaDB [sancardb]> describe usuarios; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | usuario_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(50) | NO | | NULL | | | rol | varchar(50) | NO | | NULL | | | email | varchar(100) | YES | UNI | NULL | | | password | varchar(100) | NO | | NULL | | +------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.013 sec) MariaDB [sancardb]> CREATE TABLE Ventas ( -> venta_id INT AUTO_INCREMENT PRIMARY KEY, -> fecha DATE NOT NULL, -> total DECIMAL(10, 2) NOT NULL, -> cliente_id INT, -> usuario_id INT, -> FOREIGN KEY (cliente_id) REFERENCES Clientes(cliente_id), -> FOREIGN KEY (usuario_id) REFERENCES Usuarios(usuario_id) -> ); Query OK, 0 rows affected (0.018 sec) MariaDB [sancardb]> describe ventas; +------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+----------------+ | venta_id | int(11) | NO | PRI | NULL | auto_increment | | fecha | date | NO | | NULL | | | total | decimal(10,2) | NO | | NULL | | | cliente_id | int(11) | YES | MUL | NULL | | | usuario_id | int(11) | YES | MUL | NULL | | +------------+---------------+------+-----+---------+----------------+ 5 rows in set (0.014 sec) MariaDB [sancardb]> CREATE TABLE Detalle ( -> detalle_id INT AUTO_INCREMENT PRIMARY KEY, -> venta_id INT, -> producto_id INT, -> cantidad INT NOT NULL, -> subtotal DECIMAL(10, 2) NOT NULL, -> FOREIGN KEY (venta_id) REFERENCES Ventas(venta_id), -> FOREIGN KEY (producto_id) REFERENCES Productos(producto_id) -> ); Query OK, 0 rows affected (0.020 sec) MariaDB [sancardb]> describe detalle; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | detalle_id | int(11) | NO | PRI | NULL | auto_increment | | venta_id | int(11) | YES | MUL | NULL | | | producto_id | int(11) | YES | MUL | NULL | | | cantidad | int(11) | NO | | NULL | | | subtotal | decimal(10,2) | NO | | NULL | | +-------------+---------------+------+-----+---------+----------------+ 5 rows in set (0.014 sec) MariaDB [sancardb]> CREATE TABLE Pedido ( -> pedido_id INT AUTO_INCREMENT PRIMARY KEY, -> fecha_pedido DATE NOT NULL, -> producto_id INT, -> proveedor_id INT, -> FOREIGN KEY (producto_id) REFERENCES Productos(producto_id), -> FOREIGN KEY (proveedor_id) REFERENCES Proveedor(proveedor_id) -> ); Query OK, 0 rows affected (0.021 sec) MariaDB [sancardb]> describe pedido; +--------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+----------------+ | pedido_id | int(11) | NO | PRI | NULL | auto_increment | | fecha_pedido | date | NO | | NULL | | | producto_id | int(11) | YES | MUL | NULL | | | proveedor_id | int(11) | YES | MUL | NULL | | +--------------+---------+------+-----+---------+----------------+ 4 rows in set (0.012 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> insert into clientes (nombre, apellido, telefono, correo, fecha_registro) values -> ('maria', 'gonzalez', '123456789', 'maria.gonzalez@ejemplo.com', '2024-10-01'), -> ('juan', 'perez', '234567890', 'juan.perez@ejemplo.com', '2024-10-02'), -> ('luis', 'rodriguez', '345678901', 'luis.rodriguez@ejemplo.com', '2024-10-03'), -> ('ana', 'martinez', '456789012', 'ana.martinez@ejemplo.com', '2024-10-04'), -> ('carla', 'lopez', '567890123', 'carla.lopez@ejemplo.com', '2024-10-05'), -> ('jorge', 'sanchez', '678901234', 'jorge.sanchez@ejemplo.com', '2024-10-06'), -> ('patricia', 'hidalgo', '789012345', 'patricia.hidalgo@ejemplo.com', '2024-10-07'), -> ('pedro', 'diaz', '890123456', 'pedro.diaz@ejemplo.com', '2024-10-08'), -> ('silvia', 'castillo', '901234567', 'silvia.castillo@ejemplo.com', '2024-10-09'), -> ('ramiro', 'alonso', '012345678', 'ramiro.alonso@ejemplo.com', '2024-10-10'); Query OK, 10 rows affected (0.046 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> describe direccion; +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | direccion_id | int(11) | NO | PRI | NULL | auto_increment | | cliente_id | int(11) | YES | MUL | NULL | | | calle | varchar(100) | YES | | NULL | | | ciudad | varchar(50) | YES | | NULL | | | estado | varchar(50) | YES | | NULL | | | codigo_postal | varchar(10) | YES | | NULL | | +---------------+--------------+------+-----+---------+----------------+ 6 rows in set (0.011 sec) MariaDB [sancardb]> insert into direccion (cliente_id, calle, ciudad, estado, codigo_postal) values -> (1, 'calle 1', 'medellin', 'antioquia', '050001'), -> (2, 'calle 2', 'bogota', 'cundinamarca', '110001'), -> (3, 'calle 3', 'cartagena', 'bolivar', '130001'), -> (4, 'calle 4', 'cali', 'valle del cauca', '760001'), -> (5, 'calle 5', 'barranquilla', 'atlantico', '080001'), -> (6, 'calle 6', 'pereira', 'risaralda', '660001'), -> (7, 'calle 7', 'manizales', 'caldas', '170001'), -> (8, 'calle 8', 'armenia', 'quindio', '630001'), -> (9, 'calle 9', 'bucaramanga', 'santander', '680001'), -> (10, 'calle 10', 'ibague', 'tolima', '730001'); Query OK, 10 rows affected (0.009 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from direccion; +--------------+------------+----------+--------------+-----------------+---------------+ | direccion_id | cliente_id | calle | ciudad | estado | codigo_postal | +--------------+------------+----------+--------------+-----------------+---------------+ | 1 | 1 | calle 1 | medellin | antioquia | 050001 | | 2 | 2 | calle 2 | bogota | cundinamarca | 110001 | | 3 | 3 | calle 3 | cartagena | bolivar | 130001 | | 4 | 4 | calle 4 | cali | valle del cauca | 760001 | | 5 | 5 | calle 5 | barranquilla | atlantico | 080001 | | 6 | 6 | calle 6 | pereira | risaralda | 660001 | | 7 | 7 | calle 7 | manizales | caldas | 170001 | | 8 | 8 | calle 8 | armenia | quindio | 630001 | | 9 | 9 | calle 9 | bucaramanga | santander | 680001 | | 10 | 10 | calle 10 | ibague | tolima | 730001 | +--------------+------------+----------+--------------+-----------------+---------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> describe productos; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | producto_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(100) | NO | | NULL | | | descripcion | text | YES | | NULL | | | precio | decimal(10,2) | NO | | NULL | | | stock | int(11) | NO | | NULL | | +-------------+---------------+------+-----+---------+----------------+ 5 rows in set (0.012 sec) MariaDB [sancardb]> insert into productos (nombre, descripcion, precio, stock) values -> ('arroz', 'arroz de grano largo', 15000, 100), -> ('az£car', 'az£car blanca', 5000, 200), -> ('sal', 'sal de mesa', 2000, 150), -> ('aceite', 'aceite vegetal', 12000, 80), -> ('leche', 'leche entera', 8000, 60), -> ('huevo', 'huevos de gallina', 10000, 90), -> ('pollo', 'pollo fresco', 18000, 110), -> ('carne de res', 'carne de res molida', 25000, 120), -> ('pasta', 'fideos de pasta', 6000, 140), -> ('frijoles', 'frijoles rojos', 7000, 130); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select * from pedido; Empty set (0.000 sec) MariaDB [sancardb]> select * from ventas; Empty set (0.000 sec) MariaDB [sancardb]> select * from usuario; ERROR 1146 (42S02): Table 'sancardb.usuario' doesn't exist MariaDB [sancardb]> select * from usuarios; Empty set (0.000 sec) MariaDB [sancardb]> insert into usuarios (nombre, rol, email, password) values -> ('usuario 1', 'admin', 'usuario1@ejemplo.com', 'contrase¤a1'), -> ('usuario 2', 'vendedor', 'usuario2@ejemplo.com', 'contrase¤a2'), -> ('usuario 3', 'admin', 'usuario3@ejemplo.com', 'contrase¤a3'), -> ('usuario 4', 'vendedor', 'usuario4@ejemplo.com', 'contrase¤a4'), -> ('usuario 5', 'admin', 'usuario5@ejemplo.com', 'contrase¤a5'), -> ('usuario 6', 'vendedor', 'usuario6@ejemplo.com', 'contrase¤a6'), -> ('usuario 7', 'admin', 'usuario7@ejemplo.com', 'contrase¤a7'), -> ('usuario 8', 'vendedor', 'usuario8@ejemplo.com', 'contrase¤a8'), -> ('usuario 9', 'admin', 'usuario9@ejemplo.com', 'contrase¤a9'), -> ('usuario 10', 'vendedor', 'usuario10@ejemplo.com', 'contrase¤a10'); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from usuario; ERROR 1146 (42S02): Table 'sancardb.usuario' doesn't exist MariaDB [sancardb]> select * from usuarios; +------------+------------+----------+-----------------------+--------------+ | usuario_id | nombre | rol | email | password | +------------+------------+----------+-----------------------+--------------+ | 1 | usuario 1 | admin | usuario1@ejemplo.com | contrase¤a1 | | 2 | usuario 2 | vendedor | usuario2@ejemplo.com | contrase¤a2 | | 3 | usuario 3 | admin | usuario3@ejemplo.com | contrase¤a3 | | 4 | usuario 4 | vendedor | usuario4@ejemplo.com | contrase¤a4 | | 5 | usuario 5 | admin | usuario5@ejemplo.com | contrase¤a5 | | 6 | usuario 6 | vendedor | usuario6@ejemplo.com | contrase¤a6 | | 7 | usuario 7 | admin | usuario7@ejemplo.com | contrase¤a7 | | 8 | usuario 8 | vendedor | usuario8@ejemplo.com | contrase¤a8 | | 9 | usuario 9 | admin | usuario9@ejemplo.com | contrase¤a9 | | 10 | usuario 10 | vendedor | usuario10@ejemplo.com | contrase¤a10 | +------------+------------+----------+-----------------------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from proveedor; Empty set (0.000 sec) MariaDB [sancardb]> insert into proveedor (nombre, telefono, direccion) values -> ('proveedor 1', '123456789', 'direccion 1'), -> ('proveedor 2', '234567890', 'direccion 2'), -> ('proveedor 3', '345678901', 'direccion 3'), -> ('proveedor 4', '456789012', 'direccion 4'), -> ('proveedor 5', '567890123', 'direccion 5'), -> ('proveedor 6', '678901234', 'direccion 6'), -> ('proveedor 7', '789012345', 'direccion 7'), -> ('proveedor 8', '890123456', 'direccion 8'), -> ('proveedor 9', '901234567', 'direccion 9'), -> ('proveedor 10', '012345678', 'direccion 10'); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from proveedor; +--------------+--------------+-----------+--------------+ | proveedor_id | nombre | telefono | direccion | +--------------+--------------+-----------+--------------+ | 1 | proveedor 1 | 123456789 | direccion 1 | | 2 | proveedor 2 | 234567890 | direccion 2 | | 3 | proveedor 3 | 345678901 | direccion 3 | | 4 | proveedor 4 | 456789012 | direccion 4 | | 5 | proveedor 5 | 567890123 | direccion 5 | | 6 | proveedor 6 | 678901234 | direccion 6 | | 7 | proveedor 7 | 789012345 | direccion 7 | | 8 | proveedor 8 | 890123456 | direccion 8 | | 9 | proveedor 9 | 901234567 | direccion 9 | | 10 | proveedor 10 | 012345678 | direccion 10 | +--------------+--------------+-----------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from usuarios; +------------+------------+----------+-----------------------+--------------+ | usuario_id | nombre | rol | email | password | +------------+------------+----------+-----------------------+--------------+ | 1 | usuario 1 | admin | usuario1@ejemplo.com | contrase¤a1 | | 2 | usuario 2 | vendedor | usuario2@ejemplo.com | contrase¤a2 | | 3 | usuario 3 | admin | usuario3@ejemplo.com | contrase¤a3 | | 4 | usuario 4 | vendedor | usuario4@ejemplo.com | contrase¤a4 | | 5 | usuario 5 | admin | usuario5@ejemplo.com | contrase¤a5 | | 6 | usuario 6 | vendedor | usuario6@ejemplo.com | contrase¤a6 | | 7 | usuario 7 | admin | usuario7@ejemplo.com | contrase¤a7 | | 8 | usuario 8 | vendedor | usuario8@ejemplo.com | contrase¤a8 | | 9 | usuario 9 | admin | usuario9@ejemplo.com | contrase¤a9 | | 10 | usuario 10 | vendedor | usuario10@ejemplo.com | contrase¤a10 | +------------+------------+----------+-----------------------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> insert into ventas (fecha, total, cliente_id, usuario_id) values -> ('2024-10-01', 100000, 1, 1), -> ('2024-10-02', 200000, 2, 2), -> ('2024-10-03', 150000, 3, 3), -> ('2024-10-04', 80000, 4, 4), -> ('2024-10-05', 60000, 5, 5), -> ('2024-10-06', 90000, 6, 6), -> ('2024-10-07', 110000, 7, 7), -> ('2024-10-08', 120000, 8, 8), -> ('2024-10-09', 140000, 9, 9), -> ('2024-10-10', 130000, 10, 10); Query OK, 10 rows affected (0.008 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from producto; ERROR 1146 (42S02): Table 'sancardb.producto' doesn't exist MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from venta; ERROR 1146 (42S02): Table 'sancardb.venta' doesn't exist MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from detallle; ERROR 1146 (42S02): Table 'sancardb.detallle' doesn't exist MariaDB [sancardb]> select * from detalle; Empty set (0.000 sec) MariaDB [sancardb]> insert into detalle (venta_id, producto_id, cantidad, subtotal) values -> (1, 1, 2, 20000), -> (1, 2, 1, 10000), -> (2, 3, 3, 180000), -> (2, 4, 1, 40000), -> (3, 5, 2, 100000), -> (3, 6, 1, 60000), -> (4, 7, 1, 70000), -> (5, 8, 1, 80000), -> (6, 9, 2, 180000), -> (7, 10, 3, 300000); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from detalle; +------------+----------+-------------+----------+-----------+ | detalle_id | venta_id | producto_id | cantidad | subtotal | +------------+----------+-------------+----------+-----------+ | 1 | 1 | 1 | 2 | 20000.00 | | 2 | 1 | 2 | 1 | 10000.00 | | 3 | 2 | 3 | 3 | 180000.00 | | 4 | 2 | 4 | 1 | 40000.00 | | 5 | 3 | 5 | 2 | 100000.00 | | 6 | 3 | 6 | 1 | 60000.00 | | 7 | 4 | 7 | 1 | 70000.00 | | 8 | 5 | 8 | 1 | 80000.00 | | 9 | 6 | 9 | 2 | 180000.00 | | 10 | 7 | 10 | 3 | 300000.00 | +------------+----------+-------------+----------+-----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select *from pedido; Empty set (0.000 sec) MariaDB [sancardb]> select * from proveedor; +--------------+--------------+-----------+--------------+ | proveedor_id | nombre | telefono | direccion | +--------------+--------------+-----------+--------------+ | 1 | proveedor 1 | 123456789 | direccion 1 | | 2 | proveedor 2 | 234567890 | direccion 2 | | 3 | proveedor 3 | 345678901 | direccion 3 | | 4 | proveedor 4 | 456789012 | direccion 4 | | 5 | proveedor 5 | 567890123 | direccion 5 | | 6 | proveedor 6 | 678901234 | direccion 6 | | 7 | proveedor 7 | 789012345 | direccion 7 | | 8 | proveedor 8 | 890123456 | direccion 8 | | 9 | proveedor 9 | 901234567 | direccion 9 | | 10 | proveedor 10 | 012345678 | direccion 10 | +--------------+--------------+-----------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> insert into pedido (fecha_pedido, producto_id, proveedor_id) values -> ('2024-10-01', 1, 1), -> ('2024-10-02', 2, 2), -> ('2024-10-03', 3, 3), -> ('2024-10-04', 4, 4), -> ('2024-10-05', 5, 5), -> ('2024-10-06', 6, 6), -> ('2024-10-07', 7, 7), -> ('2024-10-08', 8, 8), -> ('2024-10-09', 9, 9), -> ('2024-10-10', 10, 10); Query OK, 10 rows affected (0.007 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from pedido; +-----------+--------------+-------------+--------------+ | pedido_id | fecha_pedido | producto_id | proveedor_id | +-----------+--------------+-------------+--------------+ | 1 | 2024-10-01 | 1 | 1 | | 2 | 2024-10-02 | 2 | 2 | | 3 | 2024-10-03 | 3 | 3 | | 4 | 2024-10-04 | 4 | 4 | | 5 | 2024-10-05 | 5 | 5 | | 6 | 2024-10-06 | 6 | 6 | | 7 | 2024-10-07 | 7 | 7 | | 8 | 2024-10-08 | 8 | 8 | | 9 | 2024-10-09 | 9 | 9 | | 10 | 2024-10-10 | 10 | 10 | +-----------+--------------+-------------+--------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from detalle; +------------+----------+-------------+----------+-----------+ | detalle_id | venta_id | producto_id | cantidad | subtotal | +------------+----------+-------------+----------+-----------+ | 1 | 1 | 1 | 2 | 20000.00 | | 2 | 1 | 2 | 1 | 10000.00 | | 3 | 2 | 3 | 3 | 180000.00 | | 4 | 2 | 4 | 1 | 40000.00 | | 5 | 3 | 5 | 2 | 100000.00 | | 6 | 3 | 6 | 1 | 60000.00 | | 7 | 4 | 7 | 1 | 70000.00 | | 8 | 5 | 8 | 1 | 80000.00 | | 9 | 6 | 9 | 2 | 180000.00 | | 10 | 7 | 10 | 3 | 300000.00 | +------------+----------+-------------+----------+-----------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from direccion; +--------------+------------+----------+--------------+-----------------+---------------+ | direccion_id | cliente_id | calle | ciudad | estado | codigo_postal | +--------------+------------+----------+--------------+-----------------+---------------+ | 1 | 1 | calle 1 | medellin | antioquia | 050001 | | 2 | 2 | calle 2 | bogota | cundinamarca | 110001 | | 3 | 3 | calle 3 | cartagena | bolivar | 130001 | | 4 | 4 | calle 4 | cali | valle del cauca | 760001 | | 5 | 5 | calle 5 | barranquilla | atlantico | 080001 | | 6 | 6 | calle 6 | pereira | risaralda | 660001 | | 7 | 7 | calle 7 | manizales | caldas | 170001 | | 8 | 8 | calle 8 | armenia | quindio | 630001 | | 9 | 9 | calle 9 | bucaramanga | santander | 680001 | | 10 | 10 | calle 10 | ibague | tolima | 730001 | +--------------+------------+----------+--------------+-----------------+---------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from pedido; +-----------+--------------+-------------+--------------+ | pedido_id | fecha_pedido | producto_id | proveedor_id | +-----------+--------------+-------------+--------------+ | 1 | 2024-10-01 | 1 | 1 | | 2 | 2024-10-02 | 2 | 2 | | 3 | 2024-10-03 | 3 | 3 | | 4 | 2024-10-04 | 4 | 4 | | 5 | 2024-10-05 | 5 | 5 | | 6 | 2024-10-06 | 6 | 6 | | 7 | 2024-10-07 | 7 | 7 | | 8 | 2024-10-08 | 8 | 8 | | 9 | 2024-10-09 | 9 | 9 | | 10 | 2024-10-10 | 10 | 10 | +-----------+--------------+-------------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from proveedor; +--------------+--------------+-----------+--------------+ | proveedor_id | nombre | telefono | direccion | +--------------+--------------+-----------+--------------+ | 1 | proveedor 1 | 123456789 | direccion 1 | | 2 | proveedor 2 | 234567890 | direccion 2 | | 3 | proveedor 3 | 345678901 | direccion 3 | | 4 | proveedor 4 | 456789012 | direccion 4 | | 5 | proveedor 5 | 567890123 | direccion 5 | | 6 | proveedor 6 | 678901234 | direccion 6 | | 7 | proveedor 7 | 789012345 | direccion 7 | | 8 | proveedor 8 | 890123456 | direccion 8 | | 9 | proveedor 9 | 901234567 | direccion 9 | | 10 | proveedor 10 | 012345678 | direccion 10 | +--------------+--------------+-----------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from usuarios; +------------+------------+----------+-----------------------+--------------+ | usuario_id | nombre | rol | email | password | +------------+------------+----------+-----------------------+--------------+ | 1 | usuario 1 | admin | usuario1@ejemplo.com | contrase¤a1 | | 2 | usuario 2 | vendedor | usuario2@ejemplo.com | contrase¤a2 | | 3 | usuario 3 | admin | usuario3@ejemplo.com | contrase¤a3 | | 4 | usuario 4 | vendedor | usuario4@ejemplo.com | contrase¤a4 | | 5 | usuario 5 | admin | usuario5@ejemplo.com | contrase¤a5 | | 6 | usuario 6 | vendedor | usuario6@ejemplo.com | contrase¤a6 | | 7 | usuario 7 | admin | usuario7@ejemplo.com | contrase¤a7 | | 8 | usuario 8 | vendedor | usuario8@ejemplo.com | contrase¤a8 | | 9 | usuario 9 | admin | usuario9@ejemplo.com | contrase¤a9 | | 10 | usuario 10 | vendedor | usuario10@ejemplo.com | contrase¤a10 | +------------+------------+----------+-----------------------+--------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> SELECT c.nombre, c.apellido, v.total, v.fecha -> FROM ventas v -> JOIN cliente c ON v.cliente_id = c.cliente_id; ERROR 1146 (42S02): Table 'sancardb.cliente' doesn't exist MariaDB [sancardb]> select correo, apellido from clientes where fecha_registro between '2024-10-01' and '2024-10-31'; +------------------------------+-----------+ | correo | apellido | +------------------------------+-----------+ | maria.gonzalez@ejemplo.com | gonzalez | | juan.perez@ejemplo.com | perez | | luis.rodriguez@ejemplo.com | rodriguez | | ana.martinez@ejemplo.com | martinez | | carla.lopez@ejemplo.com | lopez | | jorge.sanchez@ejemplo.com | sanchez | | patricia.hidalgo@ejemplo.com | hidalgo | | pedro.diaz@ejemplo.com | diaz | | silvia.castillo@ejemplo.com | castillo | | ramiro.alonso@ejemplo.com | alonso | +------------------------------+-----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select correo, apellido from clientes where fecha_registro between '2024-10-01' and '2024-10-10'; +------------------------------+-----------+ | correo | apellido | +------------------------------+-----------+ | maria.gonzalez@ejemplo.com | gonzalez | | juan.perez@ejemplo.com | perez | | luis.rodriguez@ejemplo.com | rodriguez | | ana.martinez@ejemplo.com | martinez | | carla.lopez@ejemplo.com | lopez | | jorge.sanchez@ejemplo.com | sanchez | | patricia.hidalgo@ejemplo.com | hidalgo | | pedro.diaz@ejemplo.com | diaz | | silvia.castillo@ejemplo.com | castillo | | ramiro.alonso@ejemplo.com | alonso | +------------------------------+-----------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select correo, apellido from clientes where fecha_registro between '2024-10-01' and '2024-10-03'; +----------------------------+-----------+ | correo | apellido | +----------------------------+-----------+ | maria.gonzalez@ejemplo.com | gonzalez | | juan.perez@ejemplo.com | perez | | luis.rodriguez@ejemplo.com | rodriguez | +----------------------------+-----------+ 3 rows in set (0.000 sec) MariaDB [sancardb]> select nombre, apellido from cliente where fecha_registro between '2024-10-01' and '2024-10-7'; ERROR 1146 (42S02): Table 'sancardb.cliente' doesn't exist MariaDB [sancardb]> select nombre, apellido from clientes where fecha_registro between '2024-10-01' and '2024-10-7'; +----------+-----------+ | nombre | apellido | +----------+-----------+ | maria | gonzalez | | juan | perez | | luis | rodriguez | | ana | martinez | | carla | lopez | | jorge | sanchez | | patricia | hidalgo | +----------+-----------+ 7 rows in set (0.001 sec) MariaDB [sancardb]> select cliente.nombre, cliente.apellido, ventas.total from cliente inner join ventas on cliente.cliente_id = ventas.cliente_id; ERROR 1146 (42S02): Table 'sancardb.cliente' doesn't exist MariaDB [sancardb]> select clientes.nombre, clientes.apellido, ventas.total from clientes inner join ventas on clientes.clientes_id = ventas.clientes_id; ERROR 1054 (42S22): Unknown column 'clientes.clientes_id' in 'on clause' MariaDB [sancardb]> describe cliente; ERROR 1146 (42S02): Table 'sancardb.cliente' doesn't exist MariaDB [sancardb]> describe clientes; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | cliente_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(50) | NO | | NULL | | | apellido | varchar(50) | NO | | NULL | | | telefono | varchar(15) | YES | | NULL | | | correo | varchar(100) | YES | | NULL | | | fecha_registro | date | NO | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 6 rows in set (0.011 sec) MariaDB [sancardb]> select clientes.nombre, clientes.apellido, ventas.total from clientes inner join ventas on clientes.cliente_id = ventas.cliente_id; +----------+-----------+-----------+ | nombre | apellido | total | +----------+-----------+-----------+ | maria | gonzalez | 100000.00 | | juan | perez | 200000.00 | | luis | rodriguez | 150000.00 | | ana | martinez | 80000.00 | | carla | lopez | 60000.00 | | jorge | sanchez | 90000.00 | | patricia | hidalgo | 110000.00 | | pedro | diaz | 120000.00 | | silvia | castillo | 140000.00 | | ramiro | alonso | 130000.00 | +----------+-----------+-----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from detalle; +------------+----------+-------------+----------+-----------+ | detalle_id | venta_id | producto_id | cantidad | subtotal | +------------+----------+-------------+----------+-----------+ | 1 | 1 | 1 | 2 | 20000.00 | | 2 | 1 | 2 | 1 | 10000.00 | | 3 | 2 | 3 | 3 | 180000.00 | | 4 | 2 | 4 | 1 | 40000.00 | | 5 | 3 | 5 | 2 | 100000.00 | | 6 | 3 | 6 | 1 | 60000.00 | | 7 | 4 | 7 | 1 | 70000.00 | | 8 | 5 | 8 | 1 | 80000.00 | | 9 | 6 | 9 | 2 | 180000.00 | | 10 | 7 | 10 | 3 | 300000.00 | +------------+----------+-------------+----------+-----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select productos.nombre, detalle.cantidad, detalle.subtotal from productos inner join detalle on productos.producto_id = detalle.producto_id; +--------------+----------+-----------+ | nombre | cantidad | subtotal | +--------------+----------+-----------+ | arroz | 2 | 20000.00 | | az£car | 1 | 10000.00 | | sal | 3 | 180000.00 | | aceite | 1 | 40000.00 | | leche | 2 | 100000.00 | | huevo | 1 | 60000.00 | | pollo | 1 | 70000.00 | | carne de res | 1 | 80000.00 | | pasta | 2 | 180000.00 | | frijoles | 3 | 300000.00 | +--------------+----------+-----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select cliente.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from cliente inner joinn direccion on cliente.cliente_id = direccion.cliente_id; 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 'joinn direccion on cliente.cliente_id = direccion.cliente_id' at line 1 MariaDB [sancardb]> select cliente.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from cliente inner join direccion on cliente.cliente_id = direccion.cliente_id; ERROR 1146 (42S02): Table 'sancardb.cliente' doesn't exist MariaDB [sancardb]> select cliente.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from clientes inner join direccion on clientes.cliente_id = direccion.cliente_id; ERROR 1054 (42S22): Unknown column 'cliente.nombre' in 'field list' MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select clientes.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from clientes inner join direccion on clientes.cliente_id = direccion.cliente_id; +----------+----------+--------------+-----------------+---------------+ | nombre | calle | ciudad | estado | codigo_postal | +----------+----------+--------------+-----------------+---------------+ | maria | calle 1 | medellin | antioquia | 050001 | | juan | calle 2 | bogota | cundinamarca | 110001 | | luis | calle 3 | cartagena | bolivar | 130001 | | ana | calle 4 | cali | valle del cauca | 760001 | | carla | calle 5 | barranquilla | atlantico | 080001 | | jorge | calle 6 | pereira | risaralda | 660001 | | patricia | calle 7 | manizales | caldas | 170001 | | pedro | calle 8 | armenia | quindio | 630001 | | silvia | calle 9 | bucaramanga | santander | 680001 | | ramiro | calle 10 | ibague | tolima | 730001 | +----------+----------+--------------+-----------------+---------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select clientes.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from clientes where estado='antioquia' inner join direccion on clientes.cliente_id = direccion.cliente_id; 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 'inner join direccion on clientes.cliente_id = direccion.cliente_id' at line 1 MariaDB [sancardb]> select clientes.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from clientes inner join direccion on clientes.cliente_id = direccion.cliente_id where direccion.estado = 'Antioquia'; +--------+---------+----------+-----------+---------------+ | nombre | calle | ciudad | estado | codigo_postal | +--------+---------+----------+-----------+---------------+ | maria | calle 1 | medellin | antioquia | 050001 | +--------+---------+----------+-----------+---------------+ 1 row in set (0.002 sec) MariaDB [sancardb]> select clientes.nombre, direccion.calle, direccion.ciudad, direccion.estado, direccion.codigo_postal from clientes inner join direccion on clientes.cliente_id = direccion.cliente_id where direccion.ciudad = 'Medellin'; +--------+---------+----------+-----------+---------------+ | nombre | calle | ciudad | estado | codigo_postal | +--------+---------+----------+-----------+---------------+ | maria | calle 1 | medellin | antioquia | 050001 | +--------+---------+----------+-----------+---------------+ 1 row in set (0.001 sec) MariaDB [sancardb]> select * from productos -> ; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join inventario on productos.producto_id = inventario.producto_id where productos.precio < 5000 and >0; 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 '>0' at line 1 MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join inventario on productos.producto_id = inventario.producto_id where productos.precio < 5000 and > 0; 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 '> 0' at line 1 MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join inventario on productos.producto_id = inventario.producto_id where productos.precio < 5000 and inventario.stock > 0; ERROR 1146 (42S02): Table 'sancardb.inventario' doesn't exist MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join inventario on productos.producto_id = productos.producto_id where productos.precio < 5000 and productos.stock > 0; ERROR 1146 (42S02): Table 'sancardb.inventario' doesn't exist MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join productos on productos.producto_id = productos.producto_id where productos.precio < 5000 and productos.stock > 0; ERROR 1066 (42000): Not unique table/alias: 'productos' MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join productos on productos.producto_id = productos.producto_id where productos.precio < 5000 and producto -> describe productos; ERROR 1066 (42000): Not unique table/alias: 'productos' MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> describe productos; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | producto_id | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(100) | NO | | NULL | | | descripcion | text | YES | | NULL | | | precio | decimal(10,2) | NO | | NULL | | | stock | int(11) | NO | | NULL | | +-------------+---------------+------+-----+---------+----------------+ 5 rows in set (0.012 sec) MariaDB [sancardb]> select productos.nombre, productos.precio from productos inner join productos on productos.producto_id =productos.producto_id where productos.precio < 5000 and productos.stock > 0; ERROR 1066 (42000): Not unique table/alias: 'productos' MariaDB [sancardb]> select productos.nombre, productos.precio from productos where productos.precio < 5000 and productos.stock > 0; +--------+---------+ | nombre | precio | +--------+---------+ | sal | 2000.00 | +--------+---------+ 1 row in set (0.001 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select from pedidos; 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 pedidos' at line 1 MariaDB [sancardb]> select *from pedidos; ERROR 1146 (42S02): Table 'sancardb.pedidos' doesn't exist MariaDB [sancardb]> select *from pedido; +-----------+--------------+-------------+--------------+ | pedido_id | fecha_pedido | producto_id | proveedor_id | +-----------+--------------+-------------+--------------+ | 1 | 2024-10-01 | 1 | 1 | | 2 | 2024-10-02 | 2 | 2 | | 3 | 2024-10-03 | 3 | 3 | | 4 | 2024-10-04 | 4 | 4 | | 5 | 2024-10-05 | 5 | 5 | | 6 | 2024-10-06 | 6 | 6 | | 7 | 2024-10-07 | 7 | 7 | | 8 | 2024-10-08 | 8 | 8 | | 9 | 2024-10-09 | 9 | 9 | | 10 | 2024-10-10 | 10 | 10 | +-----------+--------------+-------------+--------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from clientes; +------------+----------+-----------+-----------+------------------------------+----------------+ | cliente_id | nombre | apellido | telefono | correo | fecha_registro | +------------+----------+-----------+-----------+------------------------------+----------------+ | 1 | maria | gonzalez | 123456789 | maria.gonzalez@ejemplo.com | 2024-10-01 | | 2 | juan | perez | 234567890 | juan.perez@ejemplo.com | 2024-10-02 | | 3 | luis | rodriguez | 345678901 | luis.rodriguez@ejemplo.com | 2024-10-03 | | 4 | ana | martinez | 456789012 | ana.martinez@ejemplo.com | 2024-10-04 | | 5 | carla | lopez | 567890123 | carla.lopez@ejemplo.com | 2024-10-05 | | 6 | jorge | sanchez | 678901234 | jorge.sanchez@ejemplo.com | 2024-10-06 | | 7 | patricia | hidalgo | 789012345 | patricia.hidalgo@ejemplo.com | 2024-10-07 | | 8 | pedro | diaz | 890123456 | pedro.diaz@ejemplo.com | 2024-10-08 | | 9 | silvia | castillo | 901234567 | silvia.castillo@ejemplo.com | 2024-10-09 | | 10 | ramiro | alonso | 012345678 | ramiro.alonso@ejemplo.com | 2024-10-10 | +------------+----------+-----------+-----------+------------------------------+----------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select ventas.venta_id, ventas.fecha from ventas inner join clientes on ventas.cliente_id = clientes.cliente_id where clientes.cliente_id = 6; +----------+------------+ | venta_id | fecha | +----------+------------+ | 6 | 2024-10-06 | +----------+------------+ 1 row in set (0.001 sec) MariaDB [sancardb]> select ventas.venta_id, ventas.fecha from ventas inner join clientes on ventas.cliente_id = clientes.cliente_id where clientes.cliente_id = 65; Empty set (0.000 sec) MariaDB [sancardb]> select ventas.venta_id, ventas.fecha from ventas inner join clientes on ventas.cliente_id = clientes.cliente_id where clientes.cliente_id = 10; +----------+------------+ | venta_id | fecha | +----------+------------+ | 10 | 2024-10-10 | +----------+------------+ 1 row in set (0.000 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select nombre from productos where nombre like '%o'; +--------+ | nombre | +--------+ | huevo | | pollo | +--------+ 2 rows in set (0.001 sec) MariaDB [sancardb]> SELECT nombre -> FROM productos -> WHERE stock < (SELECT stock -> FROM productos -> WHERE producto_id = (SELECT producto_id -> FROM pedido -> WHERE fecha_pedido = '2024-10-08')); +--------+ | nombre | +--------+ | arroz | | aceite | | leche | | huevo | | pollo | +--------+ 5 rows in set (0.001 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> show tables; +--------------------+ | Tables_in_sancardb | +--------------------+ | clientes | | detalle | | direccion | | pedido | | productos | | proveedor | | usuarios | | ventas | +--------------------+ 8 rows in set (0.001 sec) MariaDB [sancardb]> select * from pedido -> ; +-----------+--------------+-------------+--------------+ | pedido_id | fecha_pedido | producto_id | proveedor_id | +-----------+--------------+-------------+--------------+ | 1 | 2024-10-01 | 1 | 1 | | 2 | 2024-10-02 | 2 | 2 | | 3 | 2024-10-03 | 3 | 3 | | 4 | 2024-10-04 | 4 | 4 | | 5 | 2024-10-05 | 5 | 5 | | 6 | 2024-10-06 | 6 | 6 | | 7 | 2024-10-07 | 7 | 7 | | 8 | 2024-10-08 | 8 | 8 | | 9 | 2024-10-09 | 9 | 9 | | 10 | 2024-10-10 | 10 | 10 | +-----------+--------------+-------------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select nombre from productos where stock < (select stock from productos where producto_id from pedido where fecha_pedido = '2024-10-08')); 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 pedido where fecha_pedido = '2024-10-08'))' at line 1 MariaDB [sancardb]> select nombre from productos where stock < (select stock from productos where producto_id = (select producto_id from pedido where fecha_pedido = '2024-10-08')); +--------+ | nombre | +--------+ | arroz | | aceite | | leche | | huevo | | pollo | +--------+ 5 rows in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select producto_id from venta where fecha '2024-10-08'; 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 ''2024-10-08'' at line 1 MariaDB [sancardb]> select venta_id from venta where fecha '2024-10-08'; 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 ''2024-10-08'' at line 1 MariaDB [sancardb]> select venta_id from venta where fecha ='2024-10-08'; ERROR 1146 (42S02): Table 'sancardb.venta' doesn't exist MariaDB [sancardb]> select venta_id from ventas where fecha ='2024-10-08'; +----------+ | venta_id | +----------+ | 8 | +----------+ 1 row in set (0.000 sec) MariaDB [sancardb]> select stock from ventas where venta_id = 8 -> ; ERROR 1054 (42S22): Unknown column 'stock' in 'field list' MariaDB [sancardb]> select from productos; 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 productos' at line 1 MariaDB [sancardb]> select *from pedidos; ERROR 1146 (42S02): Table 'sancardb.pedidos' doesn't exist MariaDB [sancardb]> select *from pedido; +-----------+--------------+-------------+--------------+ | pedido_id | fecha_pedido | producto_id | proveedor_id | +-----------+--------------+-------------+--------------+ | 1 | 2024-10-01 | 1 | 1 | | 2 | 2024-10-02 | 2 | 2 | | 3 | 2024-10-03 | 3 | 3 | | 4 | 2024-10-04 | 4 | 4 | | 5 | 2024-10-05 | 5 | 5 | | 6 | 2024-10-06 | 6 | 6 | | 7 | 2024-10-07 | 7 | 7 | | 8 | 2024-10-08 | 8 | 8 | | 9 | 2024-10-09 | 9 | 9 | | 10 | 2024-10-10 | 10 | 10 | +-----------+--------------+-------------+--------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+ | venta_id | fecha | total | cliente_id | usuario_id | +----------+------------+-----------+------------+------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | +----------+------------+-----------+------------+------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> mysqldump -B -uroot -p sancarbd>c:/xampp/proyectoFinal.sql -> ; 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 'mysqldump -B -uroot -p sancarbd>c:/xampp/proyectoFinal.sql' at line 1 MariaDB [sancardb]> exit, -> ; 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 'exit,' at line 1 MariaDB [sancardb]> alter table ventas add column id_producto int; Query OK, 0 rows affected (0.007 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | NULL | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | NULL | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | NULL | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | NULL | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | NULL | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | NULL | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | NULL | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | NULL | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | NULL | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | NULL | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> alter table ventas add constraint fk_producto foreign key (id_producto) references productos(producto_id); Query OK, 10 rows affected (0.039 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | NULL | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | NULL | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | NULL | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | NULL | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | NULL | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | NULL | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | NULL | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | NULL | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | NULL | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | NULL | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> describe ventas; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | venta_id | int(11) | NO | PRI | NULL | auto_increment | | fecha | date | NO | | NULL | | | total | decimal(10,2) | NO | | NULL | | | cliente_id | int(11) | YES | MUL | NULL | | | usuario_id | int(11) | YES | MUL | NULL | | | id_producto | int(11) | YES | MUL | NULL | | +-------------+---------------+------+-----+---------+----------------+ 6 rows in set (0.011 sec) MariaDB [sancardb]> update ventas set id_venta = case venta_id -> when 1 then 5 -> when 2 then 3 -> when 3 then 8 -> when 4 then 1 -> when 5 then 7 -> when 6 then 10 -> when 7 then 2 -> when 8 then 4 -> when 9 then 9 -> when 10 teh 7 -> 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 'teh 7 end' at line 11 MariaDB [sancardb]> update ventas set id_venta = case venta_id -> when 1 then 5 -> when 2 then 3 -> when 3 then 8 -> when 4 then 1 -> when 5 then 7 -> when 6 then 10 -> when 7 then 2 -> when 8 then 4 -> when 9 then 9 -> when 10 then 6 -> end; ERROR 1054 (42S22): Unknown column 'id_venta' in 'field list' MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | NULL | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | NULL | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | NULL | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | NULL | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | NULL | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | NULL | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | NULL | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | NULL | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | NULL | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | NULL | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> update venta -> set id_producto = case venta_id -> when 1 then 3 -> when 2 then 7 -> when 3 then 1 -> when 4 then 5 -> when 5 then 10 -> when 6 then 2 -> when 7 then 8 -> when 8 then 4 -> when 9 then 6 -> when 10 then 9 -> end; ERROR 1146 (42S02): Table 'sancardb.venta' doesn't exist MariaDB [sancardb]> update ventas -> set id_producto = case venta_id -> when 1 then 3 -> when 2 then 7 -> when 3 then 1 -> when 4 then 5 -> when 5 then 10 -> when 6 then 2 -> when 7 then 8 -> when 8 then 4 -> when 9 then 6 -> when 10 then 9 -> end; Query OK, 10 rows affected (0.003 sec) Rows matched: 10 Changed: 10 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> describe ventas; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | venta_id | int(11) | NO | PRI | NULL | auto_increment | | fecha | date | NO | | NULL | | | total | decimal(10,2) | NO | | NULL | | | cliente_id | int(11) | YES | MUL | NULL | | | usuario_id | int(11) | YES | MUL | NULL | | | id_producto | int(11) | YES | MUL | NULL | | +-------------+---------------+------+-----+---------+----------------+ 6 rows in set (0.012 sec) MariaDB [sancardb]> select p.nombre -> ; ERROR 1109 (42S02): Unknown table 'p' in field list MariaDB [sancardb]> select p.nombre from productos p where p.stock < (select stock from productos where productos_id = (select id_producto from ventas where fecha = '2024-10-08')); ERROR 1054 (42S22): Unknown column 'productos_id' in 'where clause' MariaDB [sancardb]> select p.nombre from productos p where p.stock < (select stock from productos where producto_id = (select id_producto from venta where fecha = '2024-10-08')); ERROR 1146 (42S02): Table 'sancardb.venta' doesn't exist MariaDB [sancardb]> select p.nombre from productos p where p.stock < (select stock from productos where producto_id = (select id_producto from ventas where fecha = '2024-10-08')); +--------+ | nombre | +--------+ | leche | +--------+ 1 row in set (0.001 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select p.nombre from productos p where p.stock < (select stock from productos where producto_id = (select id_producto from ventas where fecha = '2024-10-08')); +--------+ | nombre | +--------+ | leche | +--------+ 1 row in set (0.001 sec) MariaDB [sancardb]> show ventas; 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 'ventas' at line 1 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> alter table productos add column valorVenta decimal(10,2); Query OK, 0 rows affected (0.006 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+------------+ | producto_id | nombre | descripcion | precio | stock | valorVenta | +-------------+--------------+----------------------+----------+-------+------------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | NULL | | 2 | az£car | az£car blanca | 5000.00 | 200 | NULL | | 3 | sal | sal de mesa | 2000.00 | 150 | NULL | | 4 | aceite | aceite vegetal | 12000.00 | 80 | NULL | | 5 | leche | leche entera | 8000.00 | 60 | NULL | | 6 | huevo | huevos de gallina | 10000.00 | 90 | NULL | | 7 | pollo | pollo fresco | 18000.00 | 110 | NULL | | 8 | carne de res | carne de res molida | 25000.00 | 120 | NULL | | 9 | pasta | fideos de pasta | 6000.00 | 140 | NULL | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | NULL | +-------------+--------------+----------------------+----------+-------+------------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> alter table productos drop column valorVenta; Query OK, 0 rows affected (0.007 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | +----------+------------+-----------+------------+------------+-------------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | +----------+------------+-----------+------------+------------+-------------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> alter table ventas add column cantidad int; Query OK, 0 rows affected (0.006 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+----------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | cantidad | +----------+------------+-----------+------------+------------+-------------+----------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | NULL | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | NULL | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | NULL | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | NULL | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | NULL | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | NULL | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | NULL | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | NULL | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | NULL | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | NULL | +----------+------------+-----------+------------+------------+-------------+----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> update ventas set cantidad = 5 where venta_id = 1; Query OK, 1 row affected (0.003 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 10 where venta_id = 2; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 3 where venta_id = 3; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 8 where venta_id = 4; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 12 where venta_id = 5; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 7 where venta_id = 6; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 4 where venta_id = 7; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 6 where venta_id = 8; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 9 where venta_id = 9; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> update ventas set cantidad = 2 where venta_id = 10; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+----------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | cantidad | +----------+------------+-----------+------------+------------+-------------+----------+ | 1 | 2024-10-01 | 100000.00 | 1 | 1 | 3 | 5 | | 2 | 2024-10-02 | 200000.00 | 2 | 2 | 7 | 10 | | 3 | 2024-10-03 | 150000.00 | 3 | 3 | 1 | 3 | | 4 | 2024-10-04 | 80000.00 | 4 | 4 | 5 | 8 | | 5 | 2024-10-05 | 60000.00 | 5 | 5 | 10 | 12 | | 6 | 2024-10-06 | 90000.00 | 6 | 6 | 2 | 7 | | 7 | 2024-10-07 | 110000.00 | 7 | 7 | 8 | 4 | | 8 | 2024-10-08 | 120000.00 | 8 | 8 | 4 | 6 | | 9 | 2024-10-09 | 140000.00 | 9 | 9 | 6 | 9 | | 10 | 2024-10-10 | 130000.00 | 10 | 10 | 9 | 2 | +----------+------------+-----------+------------+------------+-------------+----------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> update ventas set total = (select p.precio * v.cantidad from productos.p where p.producto_id = v.id_producto) where cantidad is not null; ERROR 1146 (42S02): Table 'productos.p' doesn't exist MariaDB [sancardb]> update ventas set total = (select p.precio * v.cantidad from productos where p.producto_id = v.id_producto) where cantidad is not null; ERROR 1054 (42S22): Unknown column 'p.precio' in 'field list' MariaDB [sancardb]> update ventas v -> set total = (select p.precio * v.cantidad from productos p where p.producto_id = v.id_producto) -> where v.cantidad is not null; Query OK, 10 rows affected (0.002 sec) Rows matched: 10 Changed: 10 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+----------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | cantidad | +----------+------------+-----------+------------+------------+-------------+----------+ | 1 | 2024-10-01 | 10000.00 | 1 | 1 | 3 | 5 | | 2 | 2024-10-02 | 180000.00 | 2 | 2 | 7 | 10 | | 3 | 2024-10-03 | 45000.00 | 3 | 3 | 1 | 3 | | 4 | 2024-10-04 | 64000.00 | 4 | 4 | 5 | 8 | | 5 | 2024-10-05 | 84000.00 | 5 | 5 | 10 | 12 | | 6 | 2024-10-06 | 35000.00 | 6 | 6 | 2 | 7 | | 7 | 2024-10-07 | 100000.00 | 7 | 7 | 8 | 4 | | 8 | 2024-10-08 | 72000.00 | 8 | 8 | 4 | 6 | | 9 | 2024-10-09 | 90000.00 | 9 | 9 | 6 | 9 | | 10 | 2024-10-10 | 12000.00 | 10 | 10 | 9 | 2 | +----------+------------+-----------+------------+------------+-------------+----------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> select * from productos; +-------------+--------------+----------------------+----------+-------+ | producto_id | nombre | descripcion | precio | stock | +-------------+--------------+----------------------+----------+-------+ | 1 | arroz | arroz de grano largo | 15000.00 | 100 | | 2 | az£car | az£car blanca | 5000.00 | 200 | | 3 | sal | sal de mesa | 2000.00 | 150 | | 4 | aceite | aceite vegetal | 12000.00 | 80 | | 5 | leche | leche entera | 8000.00 | 60 | | 6 | huevo | huevos de gallina | 10000.00 | 90 | | 7 | pollo | pollo fresco | 18000.00 | 110 | | 8 | carne de res | carne de res molida | 25000.00 | 120 | | 9 | pasta | fideos de pasta | 6000.00 | 140 | | 10 | frijoles | frijoles rojos | 7000.00 | 130 | +-------------+--------------+----------------------+----------+-------+ 10 rows in set (0.000 sec) MariaDB [sancardb]> Update ventas v set total = (select p.precio * v.cantidad from productos p where p.producto_id = v.id_producto where v.cantidad is not null; 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 'where v.cantidad is not null' at line 1 MariaDB [sancardb]> Update ventas v set total = (select p.precio * v.cantidad from productos p where p.producto_id = v.id_producto) where v.cantidad is not null; Query OK, 0 rows affected (0.001 sec) Rows matched: 10 Changed: 0 Warnings: 0 MariaDB [sancardb]> select * from ventas; +----------+------------+-----------+------------+------------+-------------+----------+ | venta_id | fecha | total | cliente_id | usuario_id | id_producto | cantidad | +----------+------------+-----------+------------+------------+-------------+----------+ | 1 | 2024-10-01 | 10000.00 | 1 | 1 | 3 | 5 | | 2 | 2024-10-02 | 180000.00 | 2 | 2 | 7 | 10 | | 3 | 2024-10-03 | 45000.00 | 3 | 3 | 1 | 3 | | 4 | 2024-10-04 | 64000.00 | 4 | 4 | 5 | 8 | | 5 | 2024-10-05 | 84000.00 | 5 | 5 | 10 | 12 | | 6 | 2024-10-06 | 35000.00 | 6 | 6 | 2 | 7 | | 7 | 2024-10-07 | 100000.00 | 7 | 7 | 8 | 4 | | 8 | 2024-10-08 | 72000.00 | 8 | 8 | 4 | 6 | | 9 | 2024-10-09 | 90000.00 | 9 | 9 | 6 | 9 | | 10 | 2024-10-10 | 12000.00 | 10 | 10 | 9 | 2 | +----------+------------+-----------+------------+------------+-------------+----------+ 10 rows in set (0.001 sec) MariaDB [sancardb]> select avg(total) as promedio_total_ventas from ventas; +-----------------------+ | promedio_total_ventas | +-----------------------+ | 69200.000000 | +-----------------------+ 1 row in set (0.001 sec) MariaDB [sancardb]> select sum(total) as total_ventas from ventas; +--------------+ | total_ventas | +--------------+ | 692000.00 | +--------------+ 1 row in set (0.001 sec) MariaDB [sancardb]> exit