Mainly what I don't understand is those letters next to each field example 's'.'name_subject'. Could you explain it to me please? Thank you!!
SELECT `s`.`name_subject`, `s`.`code_subject`, `s`.`credits`, `ps`.`trimester`, `s`.`component` FROM `validations_process` AS `vp` JOIN `templates` AS `t` ON `vp`.`id_template` = `t`.`id_template` JOIN `programs_subjects` AS `ps` ON `ps`.`id_program` = `t`.`id_program` JOIN `subjects` AS `s` ON `ps`.`id_subject` = `s`.`id_subject` WHERE `vp`.`id_homologate_request` = '72' AND ps.id_subject NOT IN (SELECT id_subject FROM subject_interchanges si, validations_process vp, templates t where vp.id_template = `t`.`id_template` AND `vp`.`id_homologate_request` = '72') AND `ps`.`trimester` != '0' ORDER BY `ps`.`trimester` ASC
These letters correspond to the alias you give to the table, for example
subjects
ASs
, you indicate that the subjects table has the alias s. By indicatings
.name_subject
you are querying the name_subject field of the subject table.When you do a query, you can give the tables a reference name that is just for the query you are executing. ex:
In the case that you are seeing is for a table that comes by JOIN, an example of this would be:
As you can see the table is working
local
asloc
andpersonas
asper