473,461 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What type of join is this?

Hey all,

I need to join 2 tables like the following scenario below, can anyone enlighten me as to what type of join this would be (or better yet an example of how the query would be set up)?
.....

Example -

Student Table A has 5 columns (firstname, lastname, gender, section_A_id, section_B_id)

Student Table B has 2 columns (id, sectionname)

I want this returned in 1 record...

firstname, lastname, gender, section_A_id, section_B_id, sectionname(for section_A_id), sectionname (for section_B_id)
Nov 16 '10 #1
2 1260
code green
1,726 Expert 1GB
Looks like you need to JOIN to Student Table B twice, something like
Expand|Select|Wrap|Line Numbers
  1. SELECT firstname, lastname, gender, section_A_id, section_B_id, BA.sectionname, BB.sectionname 
  2. FROM A 
  3. JOIN B AS BA ON id = section_A_id
  4. JOIN B AS BB ON id = section_B_id
Nov 16 '10 #2
Oralloy
988 Expert 512MB
@AllBeagle,

If you are guaranteed that table A will always refer to two rows in table B, code green gave you a good answer.

Otherwise, you'll need to use outer joins, something like this, perhaps....

Expand|Select|Wrap|Line Numbers
  1. SELECT firstname, lastname, gender, section_A_id, section_B_id, BA.sectionname, BB.sectionname  
  2. FROM A  
  3.    LEFT OUTER JOIN B AS BA ON BA.id = A.section_A_id 
  4.    LEFT OUTER JOIN B AS BB ON BB.id = A.section_B_id 
  5.  
Nov 16 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
3
by: BabuLives | last post by:
hai group... Join this group for .Net discussions... http://groups.google.com/group/TechdotNetIndia Regards, Satheesh
3
by: John Salerno | last post by:
I think I might create an enumeration with the values Off, Red, Yellow, Blue, and Overloaded and I might use this for bitwise comparison. So, when initializing the arrays, if I wanted to load the...
2
by: Michael Murschell | last post by:
In vb, how do I find out what type of control an object is? In other words, I want to find out if the Object LastName is a textbox or an image object.
8
by: KANAGA RATHAN V | last post by:
IAM A VB.NET PROGRAMMER I NEED TO JOIN THIS GROUP to discuss Visual Basic development issues
4
by: Joergen Bech | last post by:
Whenever no controls are selected in the VS.Net 2003 webforms designer, the Properties box defaults to "DOCUMENT", which allows me to set properties such as bgColor, bgProperties, bottomMargin,...
15
by: Leandro Ardissone | last post by:
Hi, I want to know what type is a variable. For example, I get the contents of an xml but some content is a list or a string, and I need to know what type it is. Thanks
5
by: garyusenet | last post by:
Console.WriteLine("Current OS: {0} ", Environment.OSVersion) I'm trying to find out what .OSVersion is. It returns an object which details the OS. I know it's not a method, because it doesnt...
11
by: Neo | last post by:
If i have a : typedef struct str32{ uint32_t word1; uint32_t word2; } word_array; word_array *my_array; what would be the data type of this: myarray->word1
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.