jeudi 7 juillet 2016

Get original data from different tables

I have a table Customers, and a table Salesman, inside both a name column:

    Table Customers              Salesman Table
   --name--                           --name--
    Peter                              Charlie
    Vlado                              Clint
    Landon                             Tim
                                       Armand

if I use this query:

select a.name as CustomerName, b.name as SalesmanName from Customers a, Salesman b

then I get this:

CustomerName        SalesmanName
Peter                Charlie
Vlado                Charlie
Landon               Charlie
Peter                Clint
Vlado                Clint
Landon               Clint
Peter                Tim
Vlado                Tim
Landon               Tim
Peter                Armand
Vlado                Armand
Landon               Armand

But want to get is this:

CustomerName          SalesmanName
Peter                   Charlie
Vlado                    Clint
Landon                    Tim
                        Armand

What should I do? Is possible to get those columns exactly as they are in their tables using a query?

Aucun commentaire:

Enregistrer un commentaire