Results 1 to 4 of 4

Thread: query 2 tables

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Unanswered: query 2 tables

    Hi, I have these 2 table. I need a query that will result BDStudenti.nume, Note.nota if i have BDStudenti.grupa and Note.ide

    BDStudenti

    nrmatricol int(5) PK
    cnp bigint(20)
    nume varchar(50)
    grupa int(5)


    Note

    idn int(5) PK
    nrmatricol int(5)
    ide int(5)
    nota int(5)


    I tried this but it does not work
    Code:
    SELECT Note.nota, BDStudenti.nume from Note, BDStudenti
    WHERE BDStudenti.grupa =501 and Note.ide =1
    thanks for the help

  2. #2
    Join Date
    Jul 2011
    Posts
    6

    Like the keys

    SELECT Note.nota, BDStudenti.nume from Note, BDStudenti
    WHERE BDStudenti.grupa =501 and Note.ide =1
    AND Note.nrmatricol = BDStudenti.nrmatricol

    I should say more...

    You need to bind the nrmatrocol rows in Note that match the nrmatricol primary key in BDStudenti. If you don't you will get all the rows in both tables and a lot of result you don't want.

    Ken
    Last edited by kwc; 07-17-11 at 14:17.

  3. #3
    Join Date
    Jul 2011
    Posts
    2
    thanks don't know how I didn't see that

    edit: that was exactly my problem with the code i had before
    Last edited by cipraen; 07-17-11 at 14:19.

  4. #4
    Join Date
    Jul 2011
    Posts
    6

    Wouldn't you know

    That's why companies put two programmers in one cubicle. Sometimes a little over-the-shoulder comment saves a lot of time. We all miss the obvious at times.

    Ken

Posting Permissions

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