Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting in database problem

Status
Not open for further replies.

Nightsoft

Programmer
Aug 23, 2001
50
0
0
DK
Ok this is my problem. :
I have 2 databases :
one with information about some journeys
nr two with starting date and end date for the journeys.

the reference between these database is a uniqe ID.

The thing is that when i want to show them, I want them to be order by starting date.

when i search for the posts that i need i search in a field called categori.

and i have to get the uniqe ID in the first table to get the starting dates in the second table. I can't grasp how i then can order them by starting date??

Anyone got an idea.?

Ask if you didn't understand. :) Machine code Rocks:)
 
Don't think of it like a function (which it's not). Think of it as set operations (which it is). Functions operate on discrete instances of data. Set operations work on all the members of a set at once.

Assuming that your tables are named "journeys" and "dates", and that the unique id field between them is called "id" in both tables, something like:

SELECT * from journeys, dates where journeys.id = dates.id order by dates.startdate

or (using shorthand form)

SELECT * from journeys j, dates d where j.id = d.id order by d.startdate

should do it. ______________________________________________________________________
TANSTAAFL!
 
What you really need to do is a "left join" on the id fields, then reference fields from either table and use the order by clause to sort your data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top