Home » questions » With SQL: Difference between Union All and Inner Join?

With SQL: Difference between Union All and Inner Join?

2006-08-13 00:14:51, Category: Programming & Design

Answers

  1. Mr.Noobler

    On 2006-08-13 00:23:10


    A UNION ALL is taking two of the exactly same structured tables and making them into one table. For a lack of a better example you had two tables: tblCustomersCompanyA and tblCustomersCompanyB that had the same columns, you could run a UNION ALL query to make them appear as one table. An INNER JOIN would be join a table like tblCustomersCompanyA to a table like tblSales by the means of a key column
  2. Ken H

    On 2006-08-13 00:25:30


    I don't know the answer, but I find the tutorial on the MySQL site to have good descriptions of basic concepts. Check out dev.mysql.com/doc
  3. © 2006. Sammy Z.

    On 2006-08-13 00:22:47


    union statement will combine the result-sets of multiple queries. each query in a union statement must have the same number of columns. ex: select col1, col2, col3... from table1 union select colA, colB, colC... from table2 GO every record from table 1 and table2 are returned, each record is on it's own row in a single result-set, as if it came from a single source. An inner join defines a relationship between two tables where one or more key-fields are in common. In order for a record from the two tables to be returned, every described key field must match. ex: select * from tableA a inner join tableB b on a.Field1 = b.FieldA and a.Field2 = b.FieldB GO only records from tablea and tableb where the described key fields match are returned. Some records could be omitted from either/both tableA and tableB. data from tableA and tableB will be on the same row.