If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > query 2 tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-17-11, 12:58
cipraen cipraen is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 07-17-11, 13:07
kwc kwc is offline
Registered User
 
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 13:17.
Reply With Quote
  #3 (permalink)  
Old 07-17-11, 13:13
cipraen cipraen is offline
Registered User
 
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 13:19.
Reply With Quote
  #4 (permalink)  
Old 07-17-11, 13:19
kwc kwc is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On