A
A
Andrey Romanov2021-12-06 20:31:08
MySQL
Andrey Romanov, 2021-12-06 20:31:08

How to form a query to 3 tables at once?

Good day. Can you please tell me if it is possible to form a query in such a way that the appeal is immediately to 3 tables and pull out records from them with unique values ​​in the surname column?

There are 3 tables, they have the same column names, but the data is correspondingly different. I need to take from these three tables all records with unique values ​​of the surname column. Whether it is possible to make it one request at once? And how to make it more correctly from the point of view of optimization? Thank you in advance for your help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2021-12-06
@FanatPHP

from the point of view of optimization, it’s more correct that it be one table
, then you don’t have to ask stupid questions

R
rPman, 2021-12-06
@rPman

select ... from ...
union
select ... from ...
union 
...
will produce unique rows, if you use union all then no

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question