?
Solved

sql, merge two tables (nothing in common)

Posted on 2013-10-23
2
Medium Priority
?
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Expert Comment

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

Accepted Solution

by:
Zberteoc earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

800 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