Perad Posted August 5, 2008 Share Posted August 5, 2008 Could someone briefly explain what primary keys are? I use them all the time. Are they just a unique identifier for the record or do they have a deeper meaning? Futhermore I have recently heard the word 'foriegn key' bounded around. Anyone know what this is? Regarding the Query. I have 3 tables. Users Groups Tax They look something like this. Users - id - name - pass - email Groups // Stores Members/Groups relations - user_id - group_id Tax // Stores name/id relationships. In this case type=Group; name=Group Name; tax_id=group_id - tax_id - type - name What I want to do is get userdata. This includes group data. Whats the best way to query the username, get the group the user is a member of, get the name of that group? Link to comment https://forums.phpfreaks.com/topic/118240-how-do-i-write-this-in-a-single-query/ Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 A primary key is simply a unique identifier of a record -- for example, if you had records with SSNs, you might not need to add a UID field (a.k.a. a surrogate key). As for the 2nd question, you simply need to join by following the *_id fields. Link to comment https://forums.phpfreaks.com/topic/118240-how-do-i-write-this-in-a-single-query/#findComment-609569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.