SQL

Jeslek

Banned
OK someone bugged me with a very, very, very interesting question. What is the correct syntax to do a select query on a result set? For example... (I'm unsure of the first line)

Code:
select * from
(
    select * from table1 where avalue1 in
    (
        select something from table3 where something2 = 1
    )
    union all
    select * from table2 where avalue1 in
    (
        select something from table4 where something7 = 1
    )
)
group by resultset.somevalue1
order by resultset.somevalue2;
 

Jeslek

Banned
Whaaa, I found the lexical grammar for the select query!!!!

select_into_statement ::=

SELECT [DISTINCT | ALL] {* | select_item[, select_item]...}
INTO {variable_name[, variable_name]... | record_name}
FROM {table_reference | (subquery)} [alias]
[, {table_reference | (subquery)} [alias]]...
rest_of_select_statement;
select_item ::=


{ function_name[(parameter_name[, parameter_name]...)]
| NULL
| numeric_literal
| [schema_name.]{table_name | view_name}.*
| [[schema_name.]{table_name. | view_name.}]column_name
| sequence_name.{CURRVAL | NEXTVAL}
| 'text'} [[AS] alias]
table_reference ::=


[schema_name.]{table_name | view_name}[@dblink_name]
 

Aunty Em

Well-Known Member
Well that certainly made it clearer. :D

I have to tackle SQL sometime since I've chosen to go into database programming...
 

Luis G

<i><b>Problemator</b></i>
Staff member
I have completely forgotten SQL.

btw, is not lexical grammar, that's the syntactic grammar ;)
 
Top