M
M
Max_Storm2014-05-07 20:24:42
SQL
Max_Storm, 2014-05-07 20:24:42

How to select sequentially from two tables without duplicate columns (SQL)?

There are two tables, one contains the code, dimensions and unit of measurement of materials, the other is the same, but for purchased products. It is necessary to display the data in one query so that the data on the condition from one table comes first, and after them the data from the second table.
For example: material_code_1 material_size_1 material_measurement_unit_1 material_code_2 material_size_2 material_measurement_2
unit_of_purchased_2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
svd71, 2014-05-07
@Max_Storm

there is such a wonderful UNION operator:

select shifr, size, unit from table1 where param1=:param
union
select shifr, size, unit from table2 where param1=:param

there is only one condition: the order of the columns, their size and type must be identical. Therefore, if there is a mismatched column somewhere, then it must be converted to the column from the first select.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question