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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Select Statement - I think :)

Status
Not open for further replies.

Karridy

Programmer
Feb 10, 2002
2
US
This is feeling very hard for me, but is surely very easy for many of you.
I have 2 Tables. "Events" and "Meals". Both have a columns named "EventDate" and "EventTime". I need to be able to compile a list of both and sort by event date and time. For example, a Meal @ 5:30 would place itself between a 4:00 Event, and a 6:30 Event.

PLEASE HELP ME!!!
Pending deadline doom :(

Thanks,
kaskenasy@publishingconcepts.com
 
Assuming you also have a field in these tables telling the name of the event or meal.

Select eventname name , eventdate, eventtime from events
union all
select mealname, eventdate, eventtime from meals
order by eventdate, eventtime.

If the 'name' field is not the same length in both tables pad the shorter one to match the longer one. If you are missing the field in one of the tables you can select a constant. (select 'meal ', eventdate etc.


 

what about

Select * from tableA
union
Select * from tableB
order by EventDate, ....


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top