Using SELECT on 2 or more tables

Consider the following database:

Browser table:

id | name        | description                     | stuff different from cars table
-------------------------------------------------------------------------------------
 1 | Chrome      | Some description
 2 | Firefox     | Some other description
 3 | Vivaldi     | Even more description

Car table:

id | name        | description                      | stuff different from browsers table
-------------------------------------------------------------------------------------
 1 | Hyundai     | Some korean description
 2 | Ford        | Some ford ther description
 3 | Ferrari     | Even ferrari more description

The output I need to get in PHP is 6 objects with an identifier, name and description. Can I do this with a keyword join? If so ... Like, I spent hours researching. Or maybe a different approach?

If I needed to compile a table of the output that I need to get, this would be:

id | name        | description                   
------------------------------------------------
 1 | Hyundai     | Some korean description
 2 | Ford        | Some ford ther description
 3 | Ferrari     | Even ferrari more description
 1 | Chrome      | Some description
 2 | Firefox     | Some other description
 3 | Vivaldi     | Even more description
+4
source share
1 answer

join. , , union all:

SELECT id, name, description
FROM   browsers
UNION ALL
SELECT id, name, description
FROM   cars
+5

Source: https://habr.com/ru/post/1607085/


All Articles