У меня есть две таблицы. Таблица "alldates"
состоит из столбца даты, называемого "nextdate"
. Таблица "availability"
состоит из нескольких столбцов, включая столбец даты с именем "availdate"
. Первым ключом таблицы "alldates"
является столбец "nextdate"
. Первичный ключ таблицы "availability"
- это столбец с именем "event_num"
.Как объединить данные из двух таблиц SQL?
Для целей объяснения, скажем, таблица "alldates"
заполняется 16 строк, даты 10/01/2014 through 10/16/2014
и таблица "availability"
заполняется 9 строк, например, так:
Availdate Event_num Event Description
10/01/2014 3 Joe's birthday
10/04/2014 12 Bill's dentist appt
10/04/2014 5 Buy pizza
10/05/2014 6 Clean the house
10/07/2014 7 Go to theater
10/07/2014 8 Continue forward
10/09/2014 9 Mow the grass
10/11/2014 10 Take a nap
10/15/2014 11 Fix the clock
Мне нужно создать новую таблицу, которая выглядит следующим образом:
Availdate Event_num Event Description
10/01/2014 3 Joe's birthday
10/02/2014 (from table "alldates")
10/03/2014 (from table "alldates")
10/04/2014 12 Bill's dentist appt
10/04/2014 5 Buy pizza
10/05/2014 6 Clean the house
10/06/2014 (from table "alldates")
10/07/2014 7 Go to theater
10/07/2014 8 Continue forward
10/08/2014 (from table "alldates")
10/09/2014 9 Mow the grass
10/10/2014 (from table "alldates")
10/11/2014 10 Take a nap
10/12/2014 (from table "alldates")
10/13/2014 (from table "alldates")
10/14/2014 (from table "alldates")
10/15/2014 11 Fix the clock
10/16/2014 (from table "alldates")