MariaDB [(none)]> source C:\xampp\matricula2.sql Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Database changed Query OK, 0 rows affected (0.07 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.23 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 4 rows affected (0.04 sec) Records: 4 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.04 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.15 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 6 rows affected (0.03 sec) Records: 6 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.06 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.18 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 8 rows affected (0.03 sec) Records: 8 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.05 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.18 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 6 rows affected (0.10 sec) Records: 6 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.28 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 10 rows affected (0.03 sec) Records: 10 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.20 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 6 rows affected (0.03 sec) Records: 6 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.07 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) MariaDB [matricula2]> show tables; +----------------------+ | Tables_in_matricula2 | +----------------------+ | alumcar | | alumno | | carrera | | matricula | | profcar | | profesor | +----------------------+ 6 rows in set (0.00 sec) MariaDB [matricula2]> describe alumcar; +----------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+---------+------+-----+---------+-------+ | codestu | char(3) | NO | MUL | NULL | | | codcarre | char(3) | NO | MUL | NULL | | +----------+---------+------+-----+---------+-------+ 2 rows in set (0.01 sec) MariaDB [matricula2]> select *from alumcar; +---------+----------+ | codestu | codcarre | +---------+----------+ | 001 | 002 | | 003 | 005 | | 005 | 001 | | 001 | 005 | +---------+----------+ 4 rows in set (0.00 sec) MariaDB [matricula2]> describe alumno; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | codestu | char(3) | NO | PRI | NULL | | | nombre | char(60) | NO | | NULL | | | direccion | char(50) | NO | | NULL | | | telefono | char(10) | NO | | NULL | | +-----------+----------+------+-----+---------+-------+ 4 rows in set (0.01 sec) MariaDB [matricula2]> select *from alumno; +---------+------------------+-----------+----------+ | codestu | nombre | direccion | telefono | +---------+------------------+-----------+----------+ | 001 | Juan Tobon | Cra 59 | 2335698 | | 002 | Mario Gonzales | Cra 89 | 6325984 | | 003 | Federico Aguilar | Cra 26 | 4569782 | | 004 | Angel Cuadrado | Cra 44 | 6398521 | | 005 | Catalina Escobar | Cra 78 | 4652300 | | 006 | Paulina Borja | Cra 45 | 4599632 | +---------+------------------+-----------+----------+ 6 rows in set (0.00 sec) MariaDB [matricula2]> describe carrera; +----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+----------+------+-----+---------+-------+ | codcarre | char(3) | NO | PRI | NULL | | | carrera | char(30) | NO | | NULL | | +----------+----------+------+-----+---------+-------+ 2 rows in set (0.01 sec) MariaDB [matricula2]> select * from carrera; +----------+-------------------------+ | codcarre | carrera | +----------+-------------------------+ | 001 | Ingenieria de Sistemas | | 002 | Contaduria | | 003 | Economia | | 004 | Derecho | | 005 | Ingenieria Agropecuaria | | 006 | Agronomia | | 007 | Ciencias de la salud | | 008 | Veterinaria | +----------+-------------------------+ 8 rows in set (0.00 sec) MariaDB [matricula2]> describe profesor; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | codprofe | char(3) | NO | PRI | NULL | | | nombre | char(60) | NO | | NULL | | | direccion | char(50) | NO | | NULL | | | telefono | char(10) | NO | | NULL | | +-----------+----------+------+-----+---------+-------+ 4 rows in set (0.02 sec) MariaDB [matricula2]> select *from profesor; +----------+----------------------+-----------+----------+ | codprofe | nombre | direccion | telefono | +----------+----------------------+-----------+----------+ | 001 | Pablo Juan Gutierrez | cra 45-96 | 2569856 | | 002 | Enrique Saltamontes | cra 25-63 | 2365914 | | 003 | Portacio Cartagena | cra 36-01 | 4596321 | | 004 | Federico Aguilar | cra 56-41 | 7895624 | | 005 | Alberto Cifuentes | cra 20-30 | 7895002 | | 006 | Pascual Bravo | cra 56-41 | 5698741 | +----------+----------------------+-----------+----------+ 6 rows in set (0.00 sec) MariaDB [matricula2]> describe matricula; +---------------+-----------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-----------------+------+-----+---------+-------+ | codmatri | char(3) | NO | PRI | NULL | | | codestu | char(3) | NO | MUL | NULL | | | codcarre | char(3) | NO | | NULL | | | codprofe | char(3) | NO | | NULL | | | valorsemestre | double unsigned | NO | | NULL | | +---------------+-----------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) MariaDB [matricula2]> select *from matricula; +----------+---------+----------+----------+---------------+ | codmatri | codestu | codcarre | codprofe | valorsemestre | +----------+---------+----------+----------+---------------+ | 001 | 003 | 004 | 004 | 1800000 | | 002 | 001 | 008 | 003 | 3500000 | | 003 | 004 | 007 | 006 | 2800000 | | 004 | 002 | 007 | 006 | 1950000 | | 005 | 005 | 004 | 001 | 1800000 | | 006 | 003 | 008 | 003 | 3500000 | +----------+---------+----------+----------+---------------+ 6 rows in set (0.00 sec) MariaDB [matricula2]> describe profcar; +----------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+---------+------+-----+---------+-------+ | codprofe | char(3) | NO | MUL | NULL | | | codcarre | char(3) | NO | MUL | NULL | | +----------+---------+------+-----+---------+-------+ 2 rows in set (0.01 sec) MariaDB [matricula2]> select *from profcar; +----------+----------+ | codprofe | codcarre | +----------+----------+ | 005 | 003 | | 002 | 006 | | 005 | 005 | | 003 | 008 | | 005 | 001 | | 004 | 002 | | 003 | 001 | | 004 | 004 | | 001 | 004 | | 006 | 007 | +----------+----------+ 10 rows in set (0.00 sec) MariaDB [matricula2]> select profesor.nombre from profcar inner join matricula on profcar.codprof=matricula.codprof inner join profesor on profesor.codprof=matricula.codprof; ERROR 1054 (42S22): Unknown column 'profcar.codprof' in 'on clause' MariaDB [matricula2]> select profesor.nombre from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe; +----------------------+ | nombre | +----------------------+ | Federico Aguilar | | Federico Aguilar | | Portacio Cartagena | | Portacio Cartagena | | Pascual Bravo | | Pascual Bravo | | Pablo Juan Gutierrez | | Portacio Cartagena | | Portacio Cartagena | +----------------------+ 9 rows in set (0.00 sec) MariaDB [matricula2]> select profesor.nombre from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where codcarre='001'; ERROR 1052 (23000): Column 'codcarre' in where clause is ambiguous MariaDB [matricula2]> select profesor.nombre from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where carrera.codcarre='001'; ERROR 1054 (42S22): Unknown column 'carrera.codcarre' in 'where clause' MariaDB [matricula2]> select *from carrera; +----------+-------------------------+ | codcarre | carrera | +----------+-------------------------+ | 001 | Ingenieria de Sistemas | | 002 | Contaduria | | 003 | Economia | | 004 | Derecho | | 005 | Ingenieria Agropecuaria | | 006 | Agronomia | | 007 | Ciencias de la salud | | 008 | Veterinaria | +----------+-------------------------+ 8 rows in set (0.00 sec) MariaDB [matricula2]> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where carrera.codcarre='001'; ERROR 1054 (42S22): Unknown column 'carrera.codcarre' in 'where clause' MariaDB [matricula2]> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe; +----------+----------+----------+---------+----------+----------+---------------+----------+----------------------+-----------+----------+ | codprofe | codcarre | codmatri | codestu | codcarre | codprofe | valorsemestre | codprofe | nombre | direccion | telefono | +----------+----------+----------+---------+----------+----------+---------------+----------+----------------------+-----------+----------+ | 003 | 008 | 002 | 001 | 008 | 003 | 3500000 | 003 | Portacio Cartagena | cra 36-01 | 4596321 | | 003 | 008 | 006 | 003 | 008 | 003 | 3500000 | 003 | Portacio Cartagena | cra 36-01 | 4596321 | | 004 | 002 | 001 | 003 | 004 | 004 | 1800000 | 004 | Federico Aguilar | cra 56-41 | 7895624 | | 003 | 001 | 002 | 001 | 008 | 003 | 3500000 | 003 | Portacio Cartagena | cra 36-01 | 4596321 | | 003 | 001 | 006 | 003 | 008 | 003 | 3500000 | 003 | Portacio Cartagena | cra 36-01 | 4596321 | | 004 | 004 | 001 | 003 | 004 | 004 | 1800000 | 004 | Federico Aguilar | cra 56-41 | 7895624 | | 001 | 004 | 005 | 005 | 004 | 001 | 1800000 | 001 | Pablo Juan Gutierrez | cra 45-96 | 2569856 | | 006 | 007 | 003 | 004 | 007 | 006 | 2800000 | 006 | Pascual Bravo | cra 56-41 | 5698741 | | 006 | 007 | 004 | 002 | 007 | 006 | 1950000 | 006 | Pascual Bravo | cra 56-41 | 5698741 | +----------+----------+----------+---------+----------+----------+---------------+----------+----------------------+-----------+----------+ 9 rows in set (0.00 sec) MariaDB [matricula2]> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where codcarre='001', -> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where codcarre='001'; 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 ' select * from profcar inner join matricula on profcar.codprofe=matricula.codpro' at line 1 MariaDB [matricula2]> MariaDB [matricula2]> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where carrera.codcarre='001'; ERROR 1054 (42S22): Unknown column 'carrera.codcarre' in 'where clause' MariaDB [matricula2]> select * from profcar inner join matricula on profcar.codprofe=matricula.codprofe inner join profesor on profesor.codprofe=matricula.codprofe where carrera.codcarre=001; ERROR 1054 (42S22): Unknown column 'carrera.codcarre' in 'where clause' MariaDB [matricula2]> Select profesor.nombre 'Profesor' from profesor inner Join Profcar on profcar.codprofe = profesor.codprofe where profcar.codcarre = '001'; +--------------------+ | Profesor | +--------------------+ | Alberto Cifuentes | | Portacio Cartagena | +--------------------+ 2 rows in set (0.00 sec) MariaDB [matricula2]> SELECT alumno.nombre 'Alumno' from alumno Inner Join alumcar on alumcar.codestu = alumno.codestu where alumcar.codcarre = '004'; Empty set (0.00 sec) MariaDB [matricula2]> select profesor.nombre 'Profesor' from profesor inner join profcar on profcar.codprofe=profesor.codprofe where profcar.codcarre='004'; +----------------------+ | Profesor | +----------------------+ | Federico Aguilar | | Pablo Juan Gutierrez | +----------------------+ 2 rows in set (0.00 sec) MariaDB [matricula2]> select sum(valorsemestre)'total' from matricula where codcarre='008'; +---------+ | total | +---------+ | 7000000 | +---------+ 1 row in set (0.00 sec) MariaDB [matricula2]> select matricula.valorsemestre from matricula where codcarre='008'; +---------------+ | valorsemestre | +---------------+ | 3500000 | | 3500000 | +---------------+ 2 rows in set (0.00 sec) MariaDB [matricula2]> select alumno.nombre from alumno inner join matricula on matricula.codestu=alumno.codestu where matricula.codprofe='003'; +------------------+ | nombre | +------------------+ | Juan Tobon | | Federico Aguilar | +------------------+ 2 rows in set (0.00 sec) MariaDB [matricula2]> select Max(valorsemestre)'Valor semestre mas alto' from matricula; +-------------------------+ | Valor semestre mas alto | +-------------------------+ | 3500000 | +-------------------------+ 1 row in set (0.01 sec) MariaDB [matricula2]> select avg(valorsemestre)'Valor Promedio' from matricula; +--------------------+ | Valor Promedio | +--------------------+ | 2558333.3333333335 | +--------------------+ 1 row in set (0.00 sec) MariaDB [matricula2]> select alumno.nombre from alumno where nombre like 'A%' Or nombre like '%R'; +------------------+ | nombre | +------------------+ | Federico Aguilar | | Angel Cuadrado | | Catalina Escobar | +------------------+ 3 rows in set (0.00 sec) MariaDB [matricula2]> select carrera.carrera,sum(matricula.valorsemestre)'total' from matricula inner join carrera on carrera.codcarre=matricula.codcarre group by carrera.carrera order by carrera.carrera; +----------------------+---------+ | carrera | total | +----------------------+---------+ | Ciencias de la salud | 4750000 | | Derecho | 3600000 | | Veterinaria | 7000000 | +----------------------+---------+ 3 rows in set (0.01 sec) MariaDB [matricula2]> select alumno.nombre from alumno left join matricula on matricula.codestu=alumno.codestu where matricula.codestu is null; +---------------+ | nombre | +---------------+ | Paulina Borja | +---------------+ 1 row in set (0.02 sec) MariaDB [matricula2]> exit