I am working on creating a MYSQL database of college students and I have normalized the majors (that is I made a new table full of majors and reference them in the student table via ID numbers). My problem is that some students have two majors and I can't figure out how to get the database to return both. I have two columns in the student table (major1 and major2). I want a call that will output the names of both majors. I've tried joins but the closest I've gotten is to have the student returned twice with a different major each time. Does anyone know how I can achieve this?
Thanks. That does exactly what I wanted it to do. It seams so obvious now that two left joins would do what I wanted.
What is the technique where you use t1,t2, etc. as a shortcut to the full table called?
are you doing your homework or what? if you need to write it in you paper, you better find out yourself from proper source. i might give you the wrong term like "i don't want to repeatedly copy-paste that damn long table name" technique. you might get an F then.
in case you didn't notice, without creating that shortcut name, you can never have the second join.
oh, while you are looking for the term of that shortcut name, why don't you look for the term when you want to obtain information from two separate tables like this. it has its own term. two words, start with P and J. it will really impress your teacher. he/she might not know it. that is why you need to look in proper source. you can't just tell them you get it in wiki. oh, in wiki they didn't mention that term, in case you want to look there.
Thanks, Fire Boar. I thought that aliasing was something different because in all my research I didn't see the shorthand of just saying "table1 a". Badai, I wasn't doing homework, this is for a personal project. I just wanted to learn more about the technique and I couldn't very well Google "i don't want to repeatedly copy-paste that damn long table name technique."