Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Unanswered: Need Help Writing Sql Now

    I have to find the number of orders sent to two different postal codes but to get all of the right columns, I have to use 2 different tables.

    So, I used WHERE to connect the two tables with the primary keys, but where do I use the specific criteria for the exact postal codes?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    We tend to connect tables using JOIN syntax
    Code:
    SELECT table_1.field_1
         , table_2.field_2
    FROM   table_1
     INNER
      JOIN table_2
        ON table_2.join_field = table_1.join_field
    Of course you can connect tables using the WHERE clause but this is a preferred method.

    Either way you just need to add or extend your WHERE clause e.g.
    Code:
    WHERE  table_1.field_1 = 'value'
    AND    table_2.field_2 = 'another value'
    P.S. In the future you should provide more details in your question
    George
    Home | Blog

Posting Permissions

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