sql - Select distinct on two tables -


I would like to select datas without duplicate tables

for example

  Table 1 Data 1; Data2; Data3; Data4; Data 5 table2 data1; Data2; Data 3   

Data 1, Data2, Data 3 are the same data types

table1

  | Data 1 Data2 Data 3 Data 4 Data 5 | ---------- | ---------- | ---------- | ---------- | ----- ----- | | Value 1.1 Price 2.1 Price 3.1 | Price 4.1. Value 5.1   

Table 2

  | Data 1 Data2 Data 3 | ---------- | ---------- | ---------- | | Value 1.1 Price 2.1 Price 3.1 | | Value 1.2 Price 2.2 | value3.2 | | Value1.3 | Price 2.3 | Value3.3 |   

I would like to select Data 1, Data 2, Data 3 from my two tables with a separate data1

  | Data 1 Data2 Data 3 | ---------- | ---------- | ---------- | | Value 1.1 Price 2.1 Price 3.1 | | Price 1.2 | Price 2.2 | Value3.2 | | Value1.3 | Price 2.3 | Value3.3 |   

I want to have my results in just 3 columns for example.1.1 is from table 1 and value1.2 is from table2

< In essence, you want the following: Data 1, data2, data 3 to table1 union / * without divX = "post-text" itemprop = "text">

The Association of Alternatives will complete the duplicate in all the two tables / Select Data / Data 1, Data2, Table 3 to Table 2,

However, there is still something that will make you clear Need come State:

I want to select data1 from data1, data2, my two tables with a different data1

The problem is that you do not It is said that if you make a fake data1 two tables, what should happen.

Suppose the values ​​in a line with table1 values ​​are (1, a, b) and table 2 Along with a line is (1, X, Y) . Which row should be included in the final output?
The two rows will be included in the above query because they are different in columns: data2 and data3 .

Edit for comment :

P> You still need Union , but you have to control which lines will join the union. note:. Because now your query will ensure that you see a duplicate, you can use unions all doens't trying to finish that DMBS duplicate does not exist Waste processing time < select pre> select data1, data2, table1 unions, select all data1, data2, table2 where not exist from data3 data3 (table1 * ou table1.data1 = table2.data1)

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -