Joining 4 Tables
-
Hi all, suppose I have an app that allows users to search for people based on location, degree held, skills, and experience. How would I join the following tables to achieve what I need:
Person Table
PersonID -----Pk
First Name
Last Name
City
StateEducation Table
EducationID --PK
PersonID -----FK
DegreeSkills Table
SkillID ------PK
PersonID -----FK
SkillJobHistory Table
HistoryID ----PK
PersonID -----FK
ExperienceThanks in advance for your help.
-
Hi all, suppose I have an app that allows users to search for people based on location, degree held, skills, and experience. How would I join the following tables to achieve what I need:
Person Table
PersonID -----Pk
First Name
Last Name
City
StateEducation Table
EducationID --PK
PersonID -----FK
DegreeSkills Table
SkillID ------PK
PersonID -----FK
SkillJobHistory Table
HistoryID ----PK
PersonID -----FK
ExperienceThanks in advance for your help.
As your joins are many to one (History to Person) you are going to need a number of queries and/or views to get all the different results. I would create view(s) that joined all the tables, using inner joins where where the FK is required and left joins where the FK is optional and then search that view. Alternatively use joins via the PersonID FK.
Never underestimate the power of human stupidity RAH
-
Hi all, suppose I have an app that allows users to search for people based on location, degree held, skills, and experience. How would I join the following tables to achieve what I need:
Person Table
PersonID -----Pk
First Name
Last Name
City
StateEducation Table
EducationID --PK
PersonID -----FK
DegreeSkills Table
SkillID ------PK
PersonID -----FK
SkillJobHistory Table
HistoryID ----PK
PersonID -----FK
ExperienceThanks in advance for your help.
select p.* ,e.*,s.*,jh.*
from persons p
inner join Education e on e.PersonID = p.PersonID
inner join Skills s on s.PersonID = p.PersonID
inner join JobHistory jh on jh.PersonID = p.PersonID
I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.
-
select p.* ,e.*,s.*,jh.*
from persons p
inner join Education e on e.PersonID = p.PersonID
inner join Skills s on s.PersonID = p.PersonID
inner join JobHistory jh on jh.PersonID = p.PersonID
I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.
This looks great but what about the conditions? For instance I want to find someone who meets the following conditions:
Education = Masters
Skills = Computer Networking
Experience = 6 yearsAlso I would like the search to match lower case spelling of Masters and Computer Networking, how are those 2 things I've just mentioned achieved. Thanks for your help.
-
This looks great but what about the conditions? For instance I want to find someone who meets the following conditions:
Education = Masters
Skills = Computer Networking
Experience = 6 yearsAlso I would like the search to match lower case spelling of Masters and Computer Networking, how are those 2 things I've just mentioned achieved. Thanks for your help.
Add a where clause with the conditions and user
LOWER(Education) = 'masters'
You are screwed with the 6 Years, this should have been stored as a numeric and then you could useDuration > 6
You may also want to look into SOUNDEX filtering for the text fieldsNever underestimate the power of human stupidity RAH
-
Hi all, suppose I have an app that allows users to search for people based on location, degree held, skills, and experience. How would I join the following tables to achieve what I need:
Person Table
PersonID -----Pk
First Name
Last Name
City
StateEducation Table
EducationID --PK
PersonID -----FK
DegreeSkills Table
SkillID ------PK
PersonID -----FK
SkillJobHistory Table
HistoryID ----PK
PersonID -----FK
ExperienceThanks in advance for your help.