RE: sort by date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



if i get your point: 

1 event can have more dates.. and you wanna show for each event just the
first date...


so you wanna show more from one table as the other one

in that case you should try to use the left join !! so check the manual on
left join



-----Original Message-----
From: Terry Romine [mailto:eatrom@blazing-trails.com]
Sent: woensdag 6 november 2002 15:55
To: php-db@lists.php.net
Subject:  sort by date


I have two tables, one contains event information and the other dates 
that the event takes place:

| id            | int(11)      |      | PRI | 0       | auto_increment |
| title         | varchar(100) | YES  |     | NULL    |                |
| location      | varchar(100) | YES  |     | NULL    |                |
| address       | varchar(100) | YES  |     | NULL    |                |
| contact       | varchar(100) | YES  |     | NULL    |                |
| category      | varchar(100) | YES  |     | NULL    |                |
| event_time    | varchar(200) | YES  |     | NULL    |                |
| urllink       | varchar(100) | YES  |     | NULL    |                |
| descript      | text         | YES  |     | NULL    |                |

| id         | int(11) |      | PRI | 0       | auto_increment |
| event_key  | int(11) | YES  |     | NULL    |                |
| event_date | date    | YES  |     | NULL    |                |

They are linked via dateTable.event_key=eventTable.id

I want to be able to sort by the first date that the event takes place. 
I tried:
$sql="select e.*,d.event_date from eventTable e,dateTable d where 
e.id=d.event_key order by d.event_date,d.event_key

but it still shows each date that the event takes place. I tried doing 
a min(d.event_date) as event_date and then "group by" instead of "order 
by" but still get too many results.

Any help to straighten this out?


Terry


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux