Update problem in MySQL

2002-09-26 Thread Morsky Juha

Do anyone has a idea how to Insert (create SQLQuery) from onetable to an
other table as
decripted under:

Here is the orginal Table:

Table1:

Ref   | Timestamp | ActionDate
---+-+
001  |  DEP + 2002/01/02
---+-+
001  |  ARR + 2002/01/04   
---+-+
001  |  DLV + 2002/01/15   
---+-+
002  |  ARR + 2002/02/02   
---+-+
002  |  DEP+ 2002/02/03   
---+-+
002  |  DLV + 2002/02/18
---+-+
003  |  DEP + 2002/01/12
---+-+
003  |  ARR + 2002/01/14   
---+-+
003  |  DLV + 2002/01/25 


I should update Table one to Table2, which means that insted of 9 rows I
should have row per Ref 

Table2:

Ref   | Departure   |  Arrival| Delivery
---+-+--+
001  | 2002/01/02 + 2002/01/04 | 2002/01/15
---+-+--+
002  | 2002/02/02 + 2002/02/03 | 2002/02/18
---+-+--+
003  | 2002/01/12 + 2002/01/14 | 2002/01/25
---+-+--+

Thanks for your help
Juha

  

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Update problem in MySQL

2002-09-26 Thread Mikhail Entaltsev

Juha,

select  dep.Ref, dep.ActionDate as Departure, arr.ActionDate as Arrival,
dlv.ActionDate as Delivery
from
 Table1 dep left join Table1 arr on (dep.Ref = arr.Ref and arr.Timestamp =
'ARR')
  left join Table1 dlv on (dep.Ref = dlv.Ref and
dlv.Timestamp = 'DLV')
where
dep.Ref = arr.Ref
and dep.Timestamp = 'DEP'

Best regards,
Mikhail.

- Original Message -
From: Morsky Juha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 26, 2002 10:06 AM
Subject: Update problem in MySQL


 Do anyone has a idea how to Insert (create SQLQuery) from onetable to an
 other table as
 decripted under:

 Here is the orginal Table:

 Table1:
 
 Ref   | Timestamp | ActionDate
 ---+-+
 001  |  DEP + 2002/01/02
 ---+-+
 001  |  ARR + 2002/01/04
 ---+-+
 001  |  DLV + 2002/01/15
 ---+-+
 002  |  ARR + 2002/02/02
 ---+-+
 002  |  DEP+ 2002/02/03
 ---+-+
 002  |  DLV + 2002/02/18
 ---+-+
 003  |  DEP + 2002/01/12
 ---+-+
 003  |  ARR + 2002/01/14
 ---+-+
 003  |  DLV + 2002/01/25


 I should update Table one to Table2, which means that insted of 9 rows I
 should have row per Ref

 Table2:
 
 Ref   | Departure   |  Arrival| Delivery
 ---+-+--+
 001  | 2002/01/02 + 2002/01/04 | 2002/01/15
 ---+-+--+
 002  | 2002/02/02 + 2002/02/03 | 2002/02/18
 ---+-+--+
 003  | 2002/01/12 + 2002/01/14 | 2002/01/25
 ---+-+--+

 Thanks for your help
 Juha



 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php