If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > writing Query?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-26-11, 05:19
arayici arayici is offline
Registered User
 
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

Quote:
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?
Reply With Quote
  #2 (permalink)  
Old 04-26-11, 06:08
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-26-11, 06:40
arayici arayici is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 04-26-11, 09:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On