Results 1 to 12 of 12

Thread: Join Issue

  1. #1
    Join Date
    May 2004
    Location
    bangalore
    Posts
    270

    Unanswered: 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 Jha

  2. #2
    Join Date
    Feb 2007
    Posts
    62
    Why should it be that? What is the significance of T2?

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    select * from T1 where COL1=5

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    George
    Home | Blog

  5. #5
    Join Date
    May 2004
    Location
    bangalore
    Posts
    270
    Quote Originally Posted by georgev
    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...........

  6. #6
    Join Date
    Aug 2007
    Posts
    17
    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'

  7. #7
    Join Date
    May 2004
    Location
    bangalore
    Posts
    270
    George, request you to read and understand the THREAD QUESTION. Don't just read the thread TITLE..............



    Thanks,
    Rahul Jha

  8. #8
    Join Date
    May 2004
    Location
    bangalore
    Posts
    270
    Quote Originally Posted by vivek_goel27
    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........




    Quote Originally Posted by vivek_goel27
    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

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    • 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.
    George
    Home | Blog

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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.
    George
    Home | Blog

  11. #11
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    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.

  12. #12
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by georgev
    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.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •