473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Query references same column twice

I have looked around and can't find any help for my SQL problem.

I have a Table which lists people
peopledb.
_____________
id | Name
1 | Fred
2 | Bill
3 | Bob

And a second table which references two people from the first

Partnershipsdb
____________
id | Pship1 | Pship2
1 1 2
2 1 3

I would Like to make a query which Lists both names in each
Partnership.

Result should be
Fred | Bill
Fred | Bob

I've tried queries with Select as, and am having trouble with how to go
about referencing the same column in the peopledb twice.

Any help appreciatted.

Vol

Dec 4 '06 #1
2 7693

Volition wrote:
I have looked around and can't find any help for my SQL problem.

I have a Table which lists people
peopledb.
_____________
id | Name
1 | Fred
2 | Bill
3 | Bob

And a second table which references two people from the first

Partnershipsdb
____________
id | Pship1 | Pship2
1 1 2
2 1 3

I would Like to make a query which Lists both names in each
Partnership.

Result should be
Fred | Bill
Fred | Bob

I've tried queries with Select as, and am having trouble with how to go
about referencing the same column in the peopledb twice.

Any help appreciatted.

Vol
SELECT * FROM tablea AS a
LEFT JOIN tableb AS t1 ON t1.id = a.column2
LEFT JOIN tableb AS t2 ON t2.id = a.column3
ORDER BY a.column1

Dec 4 '06 #2

strawberry wrote:
Volition wrote:
I have looked around and can't find any help for my SQL problem.

I have a Table which lists people
peopledb.
_____________
id | Name
1 | Fred
2 | Bill
3 | Bob

And a second table which references two people from the first

Partnershipsdb
____________
id | Pship1 | Pship2
1 1 2
2 1 3

I would Like to make a query which Lists both names in each
Partnership.

Result should be
Fred | Bill
Fred | Bob

I've tried queries with Select as, and am having trouble with how to go
about referencing the same column in the peopledb twice.

Any help appreciatted.

Vol

SELECT * FROM tablea AS a
LEFT JOIN tableb AS t1 ON t1.id = a.column2
LEFT JOIN tableb AS t2 ON t2.id = a.column3
ORDER BY a.column1
Strawberry,

I tend to not give out full answers to such simple cases - it looks too
much like someones class/homework. If he can't find the answer using
google - he really should find another line of work.

Dec 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason | last post by:
I will explain (or at least try to) first and then give an example after. I need to append a number of rows from several tables into one master table. Unfortunately there are certain columns...
1
by: Silvio | last post by:
Hey guys, Here's my situation: I have a table called lets say 'Tree', as illustred bellow: Tree ==== TreeId (integer)(identity) not null L1(integer)
2
by: sk | last post by:
I have a table for storing alerts (exceptional situations) occuring on devices that I monitor. Associated with each alert is an alert code, a description, the device responsible for causing the...
6
by: Rory Campbell-Lange | last post by:
The following query on some small datasets takes over a second to run. I'd be grateful for some help in understanding the explain output, and to remake the code. Looks like the sort is using up...
1
by: Chris Smith | last post by:
I've just noticed in the regular profiling information from our web application that a particular query on a fairly small database is taking about 15 seconds. The query is generated from software...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
6
by: blue875 | last post by:
A tale of two queries: One query looks like this, and runs fine. We'll call this the "Customer1 query": SELECT Customer1 overall.*, IIf(IsNull(.),0,1) AS IsField, IIf(IsNull(.),0,1) AS...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
10
by: darkenroyce | last post by:
Hi Guys I am creating a sports database and one of the features involves create drop down dialogue boxes that retrieve data from MySQL tables and provides them as <option> within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.