The following example retrieves the names and cities of all suppliers and customers in Brazil:
SELECT CompanyName, City FROM Suppliers WHERE Country = \'Brazil\' UNION SELECT CompanyName, City FROM Customers WHERE Country = \'Brazil\';
The next example retrieves the names and cities of all suppliers and customers located in Brazil:
SELECT CompanyName, City, \'Supplier\' AS Source FROM Suppliers WHERE Country = \'Brazil\' UNION SELECT CompanyName, City, \'Customer\' FROM Customers WHERE Country = \'Brazil\' ORDER BY City, Source;
The following example retrieves the names and IDs of all suppliers and customers. This union assumes that there are the same number of columns in each table.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.