Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Understanding This FROM

Status
Not open for further replies.

BootstrapperRI

Programmer
Jun 21, 2013
83
US
I'm having trouble understanding exactly what this FROM statement is doing. It's joining 'Tickets' with dfs where StoreID and EODID are the same, but it seems to be redundant with the Inner and Left joins? What are their separate purposes?

SQL:
FROM
[DB].[dbo].[Tickets] AS t
	INNER JOIN [DB].[dbo].[DayfileSummary] AS dfs ON ( dfs.StoreID = t.StoreID ) AND ( dfs.EODID = t.EODID )
	LEFT JOIN [DB].[dbo].[Stores] ON dfs.StoreID = Stores.StoreID
TIA


David
MIS/IT Director
 
why do you think it is redundant?
its a perfectly valid join, with multi column on first join, single column on second join and basically telling us

give me all records that have an exact match between tickets and dayfilesummary and also any record from stores that may match the storeid.

where the "error" may exist is that you should never have a ticket or a dayfilesummary without a store, assuming that store is a parent for both tables.
but.... if this is a ETL that is loading data onto a DB maybe this sql is identifying records from an external source that do not yet have a storeid as a possible step to ignore records on the load.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top