• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Database Question

I want to use information from two tables to create a unique combination of data. Take this example using two tables, Foo and Boo. I want to combine both tables to generate a result set shown at the end. Thanks!

I am using SQL

Foo:

ID | Name |
1 | Joe
2 | Bob

Boo
cID | Person A | Person B
1 | 1 | 2


I want my result row to look something like
cID | A_ID | A_Name | B_ID | B_Name

so in the case of getting cID = 1 I want the row to be
1 | 1 | Joe | 2 | Bob
 
select boo.cid, p1.id, p1.name, p2.id, p2.name
from Boo
inner join foo AS p1 on boo.person_a = p1.id
inner join foo as p2 on boo.person_b = p2.id
 
awesome thank you! As a side note seeing as Im starting to push the limits of the w3 schools usefulness, do you have any resource recommendation for this kind of a thing. Part of my problem is that I do not know the database vocabulary very well.

Thanks!
 
I'm not sure.

I learned from coworkers after I got my first programming job (did not learn SQL in school as that was not taught back then). I did take a class about 6 years later from New Horizons and learned SQL programming then (after I already learned it) and thought that they did a terrific job.
 
Back
Top