View Single Post
  #6 (permalink)  
Old March 24th, 2006, 09:52 AM
ajmelo ajmelo is offline
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello all
I'm a novice in SQL and want to do something like this:

I have 3 tables with the fields above
<TRUKS>
   TRAILER_NO (char)
   DATE (date)
   STATE (CHAR)
<TESTS>
   TRAILER_NO (char)
   PDT30 (float)
   PDT60 (float)
   REJECTED (boolean)
   PROTECT (boolean)
<SUPLIER>
   TRAILER_NO (char)
   DT30 (float)
   DT60 (float)
   PROTECT (boolean)

so i want to join these 3 tables whit fields TRUKS.TRAILER_NO, TESTS.PDT30, TESTS.PDT60, SUPLIER.DT30, SUPLIER.DT60, who meet the criteria as follows:
1-TRUKS.TRAILER_NO=TESTS.TRAILER_NO OR
  TRUKS.TRAILER_NO=SUPLIER.TRAILER_NO
2-TRUKS.DATE>=any_date1 AND TRUKS.DATE<=any_date2
3-TRUKS.ESTADO="F"
4-TESTS.REJECTED=False AND TESTS.PROTECT=False
5-SUPLIER.PROTECT=False

an example
<TRUKS>
TRAILER_NO DATE STATE
   21 xx F
   22 xx F
   23 xx F
   24 xx F
<TESTS>
TRAILER_NO PDT30 PDT60 REJECTED PROTECT
   21 x0 x1 False False
   22 x2 x3 False False
   22 x4 x5 True False
   24 x6 x7 False False
<SUPLIER>
TRAILER_NO DT30 DT60 PROTECT
   21 y0 y1 False
   22 y2 y3 False
   23 y4 y5 False

so the result i want is
TRAILER_NO PDT30 PDT60 DT30 DT60
   21 x0 x1 y0 y1
   22 x2 x3 y2 y3
   23 y4 y5
   24 x6 x7

help appreciated
Thank you all

Reply With Quote