SQL Statement Help Please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buddy1
    New Member
    • Sep 2007
    • 4

    SQL Statement Help Please

    I am trying to write a Select Statement. The data I need to get from Table A is Jobno, Stage, Empno, Labourhour, and Compqty, from Table B Jobno, Stage, Partshour and Startqty. Both Jobno and Stage must be equal in both tables. Any help would be greatly appreciated.
  • davef
    New Member
    • Sep 2007
    • 98

    #2
    Originally posted by buddy1
    I am trying to write a Select Statement. The data I need to get from Table A is Jobno, Stage, Empno, Labourhour, and Compqty, from Table B Jobno, Stage, Partshour and Startqty. Both Jobno and Stage must be equal in both tables. Any help would be greatly appreciated.
    Please provide some more details on the structure of the tables A and B as some joining will probably be in order to correctly pull the dataset that you need. Specifically, your Primary Keys and Foreign Keys in the tables will help.

    Comment

    • buddy1
      New Member
      • Sep 2007
      • 4

      #3
      Originally posted by davef
      Please provide some more details on the structure of the tables A and B as some joining will probably be in order to correctly pull the dataset that you need. Specifically, your Primary Keys and Foreign Keys in the tables will help.
      The Primary Key is Jobno, it links all my tables. I'm sorry but I don't know what a foreign key is. This is only my second day with SQL queries.

      Comment

      • davef
        New Member
        • Sep 2007
        • 98

        #4
        Originally posted by buddy1
        The Primary Key is Jobno, it links all my tables. I'm sorry but I don't know what a foreign key is. This is only my second day with SQL queries.
        Try something along the lines of
        Code:
        select a.Jobno, a.Stage, a.Empno, a.Labourhour, a.Compqty,
        b.Partshour, b.Startqty
        from A a inner join B b on a.Jobno=b.Jobno

        Comment

        • buddy1
          New Member
          • Sep 2007
          • 4

          #5
          Thanks for the try but it's still not working.

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            Originally posted by buddy1
            Thanks for the try but it's still not working.
            what's the error showing up?

            Code:
              
            select a.Jobno, a.Stage, a.Empno, a.Labourhour, a.Compqty,
            b.Partshour, b.Startqty
            from TableA a inner join TableB b on a.Jobno=b.Jobno

            Comment

            • buddy1
              New Member
              • Sep 2007
              • 4

              #7
              The error mesage is " Sorry-This is not a valid SQL statement." and that's it.

              Comment

              Working...