Hello!

There are two tables, one with data, the other will be filled up later ... You need to sql query to connect these two tables, so that the data from the filled table is displayed, and the second could be filled manually. How to do it?

Tell me please!

    3 answers 3

    I can also offer this option (the sample will be made as if it were a single table):

      SELECT id_one AS id, name, null AS none FROM [Table 1] WHERE ...
     UNION ALL - ALL here means "choose even if there is a repetition"
     SELECT id_two AS id, name, some_field AS none FROM [Table 2] WHERE ...
    

    The number, types and names (at least as a pseudonym after AS) of the fields in the samples must match. Actual for Microsoft SQL Server

      For example, something like this:

      Select * from table1 t1 left join table2 t2 on t1.Id=t2.Table1Id 

      Where t1.Id is the primary key in the first table, and t2.TableId is the foreign key in the second table.

        About the types of compounds can be found here .