Bring related data from a table


I have 2 tables a types and the other plates which are the following:

But I want to bring the type of that plate, how would I do it?

example: I have a plate with id 1 and it has the id_type 2 , and I want to bring the name of that type or failing that the tupla complete of that type

asked by Asdrubal Hernandez 30.09.2018 в 20:03

1 answer


Work with JOIN to join the 2 tables as they have in common the id_type and to filter by a specific value that you use where to define where you want the search to be made.

From the perspective of a Cartesian plane, the use of JOIN or also known as INNER JOIN will return the results that are linked in both tables; that is, in a scenario where a users table is linked to a posts table; this same JOIN will return all the users who have registered posts, omitting both the users without posts or the posts without users


FROM types
JOIN plates ON = plates.id_type
WHERE = 1;

The value 1 that you replace with the variable or the exact value   that you want me to help filter your search; preferably for each field that you consult precedes it by the name of the table to which it belongs to avoid ambiguities; in this way: tablaName.columnaName

answered by 30.09.2018 / 20:29