Results 1 to 4 of 4

Thread: writing Query?

  1. #1
    Join Date
    Apr 2011
    Posts
    40

    Question writing Query?

    hi all,

    i was trying to write query but could't figure out how should I join the third
    table and get a count from that table?

    Q-List for each trip, the trip code, the holiday code, the holiday name, and how many staff members are assigned to the trip

    SELECT trip_code, holiday_code, holiday_name
    FROM trips natural JOIN holidays;
    I used a NATURAL JOIN to join tables trips and holidays but i need to get a count from another table. I tried different thinks but no luck.

    can anyone help with this?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    piece of advice: ~never~ use NATURAL joins

    as for the rest of the homework assignment, go back to your course notes and look up COUNT() and GROUP BY
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2011
    Posts
    40
    Quote Originally Posted by r937 View Post
    piece of advice: ~never~ use NATURAL joins

    as for the rest of the homework assignment, go back to your course notes and look up COUNT() and GROUP BY
    I have been looking at my course notes but I could't see any example like what i need. This is a online course so I don't get too much help from my teacher either. mostly self study.

    So are you saying I don't need to join the tables here?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by arayici View Post
    So are you saying I don't need to join the tables here?
    no, i'm saying don't use NATURAL join, use INNER

    and as long as you're studying online, there are aproximately 937,000,000 SQL tutorials out there which will teach you COUNT() and GROUP BY

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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