Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Why Does This Work?
Thu, Feb 2 2006 6:56 AMPermanent Link

Stuart Kelly
Hi,

I have been looking at some old querys on a DBISAM 3.30 database.  I was wondering why the
following SQL works without a WHERE.  

Is WHERE not required?


SELECT STAFF_ID, FIRST_NAME, SURNAME,
SUM(TOTAL_PRICE - TOTAL_DISCOUNT_ALLOCATION) 'SALES',
BRANCH_NAME, BRANCH_ID, TILL_ID
FROM NORMALTRANLOG NTLOG
INNER JOIN STAFF ON (STAFF.STAFF_ID = STAFF_ID)
INNER JOIN BRANCH ON (BRANCH.BRANCH_ID = CAST(NTLOG.BRANCH_ID AS INTEGER))
AND DATE >= '2005-01-01'
AND DATE <= '2006-01-01'

GROUP BY STAFF_ID, BRANCH_ID, TILL_ID
ORDER BY SURNAME ASC, FIRST_NAME ASC


Thanks Stuart
Thu, Feb 2 2006 8:06 AMPermanent Link

"Ralf Mimoun"
Stuart Kelly wrote:
> Hi,
>
> I have been looking at some old querys on a DBISAM 3.30 database.  I
> was wondering why the following SQL works without a WHERE.
>
> Is WHERE not required?

No.

Ralf

Thu, Feb 2 2006 8:25 AMPermanent Link

Eryk Bottomley
Stuart,

> I have been looking at some old querys on a DBISAM 3.30 database.  I was wondering why the
> following SQL works without a WHERE.  
>
> Is WHERE not required?

It works because in SQL89 there was no JOIN keyword and joins therefore
had to be expressed as WHERE conditions. In order to maintain backward
compatibility with SQL89 while also supporting SQL92 most engines
therefore lump both JOIN and WHERE conditions together for processing
and as a side effect allow you to create (logically) badly formed
expressions like the one you quoted.

Eryk
Image