Subject Re: [firebird-support] Re: SQL for master-detail
Author Helen Borrie
At 08:41 AM 28/12/2007, you wrote:
>Ed Dressel wrote:
> >> select 1 from DetailInfo d where ...
> >
> > what does the '1' do in this SQL?
> >
>
>You have to have something in the field list, but you are not
>interested in anything in particular. So, "1" is convenient - but
>you could just as well use "*" (select * from ...).

Actually, that's not quite correct.

SELECT 1 actually outputs a single value -- a derived field (the number 1, 2 bytes for smallint) -- for each record found that matches the search criteria, i.e., 2 bytes for each record found. Select * returns ALL fields for each record found. For an EXISTS query it probably doesn't make a lot of difference to what is floating about in memory but it's not going to be true where intermediate output is actually stored in a buffer somewhere, or final output is returned to the caller.

./heLen



>--
>Aage J.
>
>
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://www.firebirdsql.org and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>