Solved

sql, merge two tables (nothing in common)

Posted on 2013-10-23
2
376 Views
Last Modified: 2013-10-24
hello,

we have two different tables, with fields: date, name event, ....

one table = events
one table = seminars


how can we, combine those, in a query to obtain a list, ordered by date


exemple:

table event, contains:

idevent 1 date 1/01/2013 name: test event
idevent 2 date 2/02/2013 name: test event 2

table seminar, contains:

idseminar 1 date 15/01/2013 name= seminar 1


the result in my webpage should be:


idevent 1 date 1/01/2013 name: test event
idseminar 1 date 15/01/2013 name= seminar 1
idevent 2 date 2/02/2013 name: test event 2



how can we do this, someone any ideas? thx in advance

kristof
0
Comment
Question by:fedkris
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 39594040
Classic homework assignment.  ;)
0
 
LVL 26

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39594652
Basically you want a union of the 2 events interlaced(sorted) by date:
select 
	idevent as EventId,
	date as EventDate,
	name as EventName
from
	events
union all
select 
	idseminar as EventId,
	date as EventDate,
	name as EventName
from
	seminar
order by
	EventDate,
	EventName

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now