Solved

sql, merge two tables (nothing in common)

Posted on 2013-10-23
2
381 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

831 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