Помогите создать запрос

Grey
Дата: 04.12.2002 16:17:24
есть 3 таблицы :

slAccountItem(slAccountItem_slAccount_ID,slAccountItem_slInOut_ID,slAccountItem_total_real)


slAccount(slAccount_ID,slAccount_dcEmploye_IDбslAccount_slCard_ID)

slCard (slCard_ID, slCard_date)

запрос
SELECT slAccount_dcEmploye_ID , slAccountItem_slInOut_ID,slAccountItem_total_real from slAccountItem


INNER JOIN slAccount ON slAccountItem_slAccount_ID = slAccount_ID
INNER JOIN slCard ON slCard_ID = slAccount_slCard_ID

WHERE slCard_date = '10.01.2002'

выводит slAccountItem_total_real для всех dcEmploye по всем slInOut_ID, которые есть в slAccountItem для конкретного dcEmploye

необходимо , чтобы выводило не только slInOut_ID которые есть в есть в slAccountItem для конкретного dcEmploye, но и те которых у него нет, а есть у других, т.е. например имеется (выдает мой запрос ):

slAccount_dcEmploye_ID  slAccountItem_slInOut_ID     slAccountItem_total_real

5 1 200
6 2 300

надо, чтобы было :

slAccount_dcEmploye_ID  slAccountItem_slInOut_ID     slAccountItem_total_real

5 1 200
5 2 null
6 2 300
6 1 null

Помогите, пожалуйста.
Белов Владимир
Дата: 04.12.2002 16:30:40
используй
left join

Да, кстати
inner не обязательно указывать, сервер использует его по умолчанию
Grey
Дата: 04.12.2002 16:33:39
left join не помогает , то же самое выдаёт, что и INNER JOIN, вот запрос :

SELECT slAccount_dcEmploye_ID AS E_ID, slAccountItem_slInOut_ID,slAccountItem_total_real from slAccountItem

LEFT JOIN slAccount ON slAccountItem_slAccount_ID = slAccount_ID
LEFT JOIN slCard ON slCard_ID = slAccount_slCard_ID
WHERE slCard_date = '10.01.2002'
funikovyuri
Дата: 04.12.2002 16:45:36
тогда используй right join :)
Grey
Дата: 04.12.2002 16:49:23
right join бред выводит , не то что надо
funikovyuri
Дата: 04.12.2002 16:50:34
full join?
Grey
Дата: 04.12.2002 16:56:39
full join тоже самое выводит , что и right join (
funikovyuri
Дата: 04.12.2002 17:03:10
Если не трудно-приведите скрипты таблиц
Grey
Дата: 04.12.2002 17:10:46
Пожалуйста :

CREATE TABLE [dbo].[slAccount] (

[slAccount_dcEmploye_ID] [int] NOT NULL ,
[slAccount_ID] [int] IDENTITY (1, 1) NOT NULL ,
[slAccount_slCard_ID] [int] NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[slAccountItem] (
[slAccountItem_ID] [int] IDENTITY (1, 1) NOT NULL ,
[slAccountItem_total_real] [float] NOT NULL ,
[slAccountItem_slInOut_ID] [int] NULL ,
[slAccountItem_slAccount_ID] [int] NOT NULL ,
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[slCard] (
[slCard_ID] [int] IDENTITY (1, 1) NOT NULL ,
[slCard_date] [datetime] NOT NULL
) ON [PRIMARY]
GO
MiCe
Дата: 04.12.2002 17:38:25
так не пойдет?
SELECT     slAccount.slAccount_dcEmploye_ID, slAccountItem.slAccountItem_slInOut_ID, slAccountItem.slAccountItem_total_real

FROM slCard INNER JOIN
slAccount ON slCard.slCard_ID = slAccount.slAccount_slCard_ID RIGHT OUTER JOIN
slAccountItem ON slAccount.slAccount_ID = slAccountItem.slAccountItem_slAccount_ID
WHERE (slCard.slCard_date = '10.01.2002')