There are two tables:

| A | B | C | 

and

 | AА | D | E | F | 

I need to build such a query that will give at the output

 | A | B | C | null | null | null | | AA | null | null | D | E | F | 

Those. add two tables into one, and the fields A and AA should be added in one column, since there are different data of the same format.
I am trying to implement this JOIN, but it turns out only this way:

 | A | B | C | AA | D | E | 

Tell me an example of implementation, and is it possible within the framework of MYSQL in general? ..

Update

An important point: the number of columns in the tables is different, and when generating the result, the WHERE condition A> = value1 and WHERE AA> = value1 for each table will be used, respectively.

    2 answers 2

    If I understand correctly, then you need UNION

      SELECT A ,B ,C ,NULL ,NULL FROM Table1 UNION ALL SELECT AA ,NULL ,NULL ,D ,E FROM Table2 
    • it looks like an ideal ... but how to sort the result by the field A (AA)? .. - deivan_
    • Wrap this query in another 'SELECT': 'SELECT * FROM (SELECT ...) X ORDER BY <field>' - Donil

    In principle, there is nothing difficult:

     SELECT CONCAT(t1.A, t2.AA), t1.B, t1.C, t2.D, t2.E FROM table1 t1 INNER JOIN table2 t2 
    • displays a syntax error ... - deivan_