Monday, February 20, 2012

Join Issue

I have below 2 tables......

T1
COL1 COL2
1 2
5 6

T2
COL1 COL2
1 2
8 9

I need a query which will return me the data from T1 and the resultset should be......

COL1 COL2
5 6

Thanks,
Rahul JhaWhy should it be that? What is the significance of T2?|||select * from T1 where COL1=5|||http://w3schools.com/sql/sql_join.asp

Have a thorough read of the above link and give it a try.
Post your attempts back here regardless of if you are successful or not.

-George|||http://w3schools.com/sql/sql_join.asp

Have a thorough read of the above link and give it a try.
Post your attempts back here regardless of if you are successful or not.

-George

What exactly you wanted to proove from the above link is not know to me GEORGE. I like staraight talks......... hence would expect you to write the direct comment......... If you want me to understand what excatly the joins are, then you are the wrong person for this thread (Which I have mentioned even in my earlier threads)..... hence request you to keep out of it......

I was asked this question in an interview a long back. All of a sudden it came in my mind and gave a try. But didn't get through it......... Hence posted it to you guys......... :):) :)|||my question is same.. What is the significance of T2???
and if u know that what r the data in the table then

select * from t1 where col1='5'|||George, request you to read and understand the THREAD QUESTION. Don't just read the thread TITLE...........

Thanks,
Rahul Jha|||my question is same.. What is the significance of T2???

Don't know what is the significance of T2...... As said that I was asked this question a long back in an interview......

and if u know that what r the data in the table then

select * from t1 where col1='5'

Even I said the same answer...... but he wanted this through IF EXISTS and LEFt OUTER JOIN...... I didn't get any way to write the type of query that was been asked......

Thanks,
Rahul Jha|||Your question doesn't make sense
Therefore LoztInSpace and jezemine's answers are perfectly correct
What's the point in knowing the answer without knowing how you got there?
The link provided explains the most commonly used joins with very simple examples of how to use them.
Here's a clue... The join type starts with an "L" and without clarification of your questions I'm going to guess at you needing an "AND" clause as well.

Oh and if you were interviewing and got an SQL question - wouldn't it be nice to learn the answer yourself, so you could answer it in future interviews?

And you don't like straight talks, you like the answer on the plate - and you're not getting it on this one.|||And Rahul, I did read the entire thread and supplied a very useful answer (if I do say so myself). I'm trying to help you to help yourself - but clearly my advice is not appreciated so I am going to hold back on giving it to you from now on. I don't think you appreciate how many of your previous questions I have helped you on.|||actually my initial answer was wrong. try this:

select 5 as COL1, 6 as COL2

It's bulletproof because it will work even if the tables don't exist, and it works on any database.|||And Rahul, I did read the entire thread and supplied a very useful answer (if I do say so myself). I'm trying to help you to help yourself - but clearly my advice is not appreciated so I am going to hold back on giving it to you from now on. I don't think you appreciate how many of your previous questions I have helped you on.

why should he bother learning the intricacies of relational databases to do his job when you are always here to do his job for him. it is a lot more efficient to just ask you.

this is why, and you may have noticed, I write very little code for posters. I tend to nudge people in certain directions and give advice so that they will be more apt to figure things out on their own because that is the only way to learn how to program.

No comments:

Post a Comment