Subject RE: [firebird-support] Temporary tables
Author Garrett Smith
Ah, sorry, correction...the problem with joins (and I think this is also
a problem with the view solution) is that I want to select something
like:

select * from ... where name = 'Blah'

Note there's no table qualifier. I.e. I want the thing I'm querying to
have a name column that is a merging of foo.name and bar.name. Thus the
temporary table.



-- Garrett

Garrett Smith wrote:
> This could be the best approach -- I was just trying to keep the SQL
> simple. But I'm probably past that point :)
>
> -- Garrett
>
> Adomas Urbanavicius wrote:
>> Why not
>> View or query
>>
>> select * from foo
>> left join bar on
>> foo.id = bar.id
>> where foo.name = 'Baz'
>> or foo.status = 1
>> /*
>> or any other :
>> bar.status = 1
>> bar.name = 'Blah'
>> */
>>
>>
>>
>>>
>>> I have several tables that I want to query as if their rows were in
>>> a single table. My thinking was to use a temporary table and execute
>>> multiple 'select into' queries to populate it and then run a final
>>> select against it.
>>>
>>> E.g., given two tables:
>>>
>>> foo ( id integer, name varchar)
>>> bar ( id integer, name varchar, status integer)
>>>
>>> I want a structure looks like:
>>>
>>> some_structure (
>>> name varchar,
>>> status integer,
>>> foo_name varchar,
>>> bar_name varchar,
>>> bar_status integer)
>>>
>>> so I can run queries like:
>>>
>>> select id from some_structure where name = 'Baz' or status = 1;
>>> select id from some_structure where foo_name = 'Baz' or bar_status
>>> = 1;
>>>
>>> Rows from table foo would NULL values for status. The underlying
>>> applications lets users select objects (represented by id) by
>>> specifying property name values. We validate input to ensure that an
>>> unqualified properties (e.g. 'name', as opposed to 'bar_name') have
>>> compatible types.
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> ------------------------ Yahoo! Groups Sponsor
>> --------------------~--> $4.98 domain names from Yahoo!. Register
>> anything. http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/67folB/TM
>>
>
--------------------------------------------------------------------~->
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~--> $4.98 domain names from Yahoo!. Register
> anything. http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/67folB/TM
>
--------------------------------------------------------------------~->
>
>
> Yahoo! Groups Links
>
>
>