error in running the join query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • progvar
    New Member
    • Feb 2008
    • 40

    error in running the join query

    Hi!
    i am facing a probleum while excuting the query having join operator
    i am using sql server 6.0 and my query is

    Select BABLU.COM_NAME, BABLU.INDNT,VEE R.ADDRESS From BABLU Join VEER on BABLU.COM_NAME = VEER.COM_NAME
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    What is the error u r getin ?

    Comment

    • progvar
      New Member
      • Feb 2008
      • 40

      #3
      Hi
      THIS IS THE ERROR " SYNTAX ERROR NEAR VEER"




      Originally posted by radcaesar
      What is the error u r getin ?

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Try specifying if you want an INNER, LEFT or RIGHT join...

        -- CK

        Comment

        • progvar
          New Member
          • Feb 2008
          • 40

          #5
          HI!
          NO ONE EXECUTED CORRECTLY, EVERY JOIN WHETHER IT IS INNER JOIN ,LEFT OR RIGHT JOIN
          PLEASE PROVIDE SOME HELP



          Originally posted by ck9663
          Try specifying if you want an INNER, LEFT or RIGHT join...

          -- CK

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            Please provide more info.

            Paste same sample rows (it does not have to be the actual data) here and the query what you have so far.

            -- CK

            Comment

            • progvar
              New Member
              • Feb 2008
              • 40

              #7
              Hi!
              i have two tables customer and sales in both tables "cus_id " column name is common and i am using the query

              SELECT CUSTOMER.FIRST_ NAME,CUSTOMER.L AST_NAME,SALES. DATE FROM CUSTOMER LEFT OUTER JOIN SALES
              ON CUSTOMER.CUS_ID = SALES.CUS_ID
              i want to get all the rows from customer tables and some from sales which matched in both tables

              with regareds
              varinder



              Originally posted by ck9663
              Please provide more info.

              Paste same sample rows (it does not have to be the actual data) here and the query what you have so far.

              -- CK

              Comment

              • ck9663
                Recognized Expert Specialist
                • Jun 2007
                • 2878

                #8
                What error are you getting?

                -- CK

                Comment

                • progvar
                  New Member
                  • Feb 2008
                  • 40

                  #9
                  SYNTAX ERROR NEAR JOIN
                  BUT I AM NOT GETTING WHAT IS WRONG IN MY CODE



                  Originally posted by ck9663
                  What error are you getting?

                  -- CK

                  Comment

                  • deric
                    New Member
                    • Dec 2007
                    • 92

                    #10
                    Have you tried using aliases?

                    SELECT C.FIRST_NAME,C. LAST_NAME,S.DAT E FROM CUSTOMER C LEFT OUTER JOIN SALES S
                    ON C.CUS_ID = S.CUS_ID

                    And if you'd like to get only the rows that has the same CUS_ID from both tables then you might want to use INNER JOIN.

                    Comment

                    • progvar
                      New Member
                      • Feb 2008
                      • 40

                      #11
                      Hi
                      THIS QUERY IS ALSO SHOWING THE SAME ERROR
                      "INCORRECT SYNTAX NEAR LEFT"


                      Originally posted by deric
                      Have you tried using aliases?

                      SELECT C.FIRST_NAME,C. LAST_NAME,S.DAT E FROM CUSTOMER C LEFT OUTER JOIN SALES S
                      ON C.CUS_ID = S.CUS_ID

                      And if you'd like to get only the rows that has the same CUS_ID from both tables then you might want to use INNER JOIN.

                      Comment

                      • ck9663
                        Recognized Expert Specialist
                        • Jun 2007
                        • 2878

                        #12
                        Where are you running this?

                        -- CK

                        Comment

                        • progvar
                          New Member
                          • Feb 2008
                          • 40

                          #13
                          Hi!
                          I AM RUNNING THIS QUERY IN SQL SERVER 6.0 QUERY ANALYZER


                          Originally posted by ck9663
                          Where are you running this?

                          -- CK

                          Comment

                          • ck9663
                            Recognized Expert Specialist
                            • Jun 2007
                            • 2878

                            #14
                            Originally posted by progvar
                            Hi!
                            I AM RUNNING THIS QUERY IN SQL SERVER 6.0 QUERY ANALYZER
                            The query seems to be correct...


                            Code:
                            SELECT C.FIRST_NAME,C.LAST_NAME,S.DATE 
                            FROM CUSTOMER C 
                            LEFT OUTER SALES S ON C.CUS_ID = S.CUS_ID
                            -- CK

                            Comment

                            • deric
                              New Member
                              • Dec 2007
                              • 92

                              #15
                              I don't know if SQL Server 6.0 can support Join statements.. I don't have version 6.0 here.

                              You may code it differently, like:

                              SELECT CUSTOMER.FIRST_ NAME, CUSTOMER.LAST_N AME, SALES.DATE
                              FROM CUSTOMER, SALES
                              WHERE CUSTOMER.CUS_ID = SALES.CUS_ID

                              The difference of that query from the query with Join statement is that Join statement could retrieve data faster.

                              Comment

                              Working...