query help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FRED

    #1

    query help

    hi,

    I have tried but just cannot work it out so i am asking for help.. please
    :-)

    I have a query that does this:

    select all the records in sales that don't have a corresponding record in
    commissions based on a field called imei in both.
    (this will tell me what records i have in my sales database that my supplier
    has not paid me commission for).

    but as i have more than one supplier i now need to amend the query to ask
    the same info but also to get the supplier from a third table. so i want to
    ask:

    select all the records in sales that don't have a corresponding record in
    commissions based on a field called imei in both AND in the results also
    display the supplier which can be found in a table called handsets that also
    has a field called imei

    imei is unique in each table.. handsets,commis sions and sales and there
    should be a record

    everytime i try to right it it brings back many thousands of records in
    stead of a few hundred as expected.

    thanks, your help is appreciated.

    sean


  • Aggro

    #2
    Re: query help

    FRED wrote:
    [color=blue]
    > select all the records in sales that don't have a corresponding record in
    > commissions based on a field called imei in both.
    > (this will tell me what records i have in my sales database that my supplier
    > has not paid me commission for).
    >
    > but as i have more than one supplier i now need to amend the query to ask
    > the same info but also to get the supplier from a third table.[/color]

    Perhaps:

    select * from supplier
    left join supplier on supplier.id=sal es.supplier_id
    left join commissions on sales.imei=comm issions.imei
    where commissions.ime i is null;

    Comment

    Working...