Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    9

    Unanswered: i need nested Query

    Hi all
    I have a 2 tables register and Pay and join them with memid
    Register table :
    MemID
    and Pay table :
    date_pay
    kind_insure
    discount
    total_price

    i did write query like this to join to table but i need get sum of discount too.
    Code:
    SELECT Register.memid, Pay.date_pay, Pay.kind_insure,Pay.discount, Pay.total_price
    FROM Reg INNER JOIN Pay ON Reg.memid = pay.memid;
    i know write this query as nested query but i can't do it.
    please trim my code
    thank's

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by unforgiven747 View Post
    I have a 2 tables register and Pay and join them with memid
    Register table :
    MemID
    and Pay table :
    date_pay
    kind_insure
    discount
    total_price
    How can you create a jon on Reg.memid = pay.memid while, in the description of the table Pay, there is no column named MemID ?
    Have a nice day!

  3. #3
    Join Date
    Jun 2010
    Posts
    9
    Quote Originally Posted by Sinndho View Post
    How can you create a jon on Reg.memid = pay.memid while, in the description of the table Pay, there is no column named MemID ?
    sorry i forgot to write it.
    Register table :
    MemID

    and Pay table :
    MemID
    date_pay
    kind_insure
    discount
    total_price

    can you make nested query. it's vital for me .
    thank's again

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You could use:
    Code:
    SELECT MemID
         , date_pay
         , kind_insure
         , discount
         , total_price
      FROM Pay 
     WHERE Pay.MemID = ( SELECT MemID
                         FROM Register 
                       );
    This would yield the same data set as the INNER JOIN you're using know, but I don't see any reason to do so.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •