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 > Data Access, Manipulation & Batch Languages > ANSI SQL > Join Issues

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-06, 21:50
koncept koncept is offline
Registered User
 
Join Date: Jul 2006
Posts: 26
Join Issues

I am trying to write a query to show me every thing from table 1 (table one is called equipment) and only the information from table 2 (called equip_out) related to the equipment item with some restrictions

equipment
equip_location = variable
deleted = 0

equip_out
equip_in = null

Code:
SELECT equipment.equip_name, equip_out.student_id, equip_out.time_out
FROM equipment
full outer JOIN equip_out ON equipment.equip_id=equip_out.equip_id
where equipment.deleted = 0
there is a column called time_in in equip_out that should only be joined with the equipment list if that field is null. the equipment list should include all fields where the column deleted is 0 (bc of logging issues i do not want anything removed ever) and equip_location = variable (variable is passed in when the query is built in vb)

this one has me stumped, if its not possible just let me know. i am going to keep working on it and will post a solution if i find one.

thanks in advance

Last edited by koncept; 12-04-06 at 21:54.
Reply With Quote
  #2 (permalink)  
Old 12-04-06, 22:13
koncept koncept is offline
Registered User
 
Join Date: Jul 2006
Posts: 26
well i have a solution, but it does not seem like it would be the best available one so if someone comes up with one better that would be great.

my solution is to use a view (stored procedure equiv in sql 2k5 express) to do the limiting on equip_out and then use that view in the join
Reply With Quote
  #3 (permalink)  
Old 12-04-06, 23:11
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
What? A view is the equivelent to a stored procedure in sql 2k5 express? When did that happen?
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #4 (permalink)  
Old 12-05-06, 06:06
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
select equipment.equip_name
     , equip_out.student_id
     , equip_out.time_out
  from equipment
left outer
  join equip_out 
    on equip_out.equip_id = equipment.equip_id 
   and equip_out.time_in is null  
 where equipment.deleted = 0
__________________
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