Danny Tramnitzke wrote:
> 
> Hi all
> 
> I want to have a alias name of a Table within a SELECT - Statement.

Then please use (as described in the reference manual) the <reference_name>: see:


FROM clause 

A FROM clause specifies a table in a table expression that is formed from one or more 
tables.

Syntax

<from_clause> ::= FROM <from_table_spec>,...

and
from_table_spec

FROM TABLE specification (from_table_spec) 

Each FROM TABLE specification ( from_table_spec ) in a FROM clause specifies no, one, 
or any number of table identifiers. 

Syntax

<from_table_spec> ::= <table_name> [<reference_name>]
| <result_table_name> [<reference_name>]
| (<query_expression>) [<reference_name>]
| <joined_table>

Explanation

Reference name

If a FROM TABLE specification does not contain a reference name, the table name or 
result table name is the table identifier.

If a FROM TABLE specification contains a reference name, the reference name is the 
table identifier.

Each reference name must be different from each identifier that specifies a table 
name. If a result table name is a table identifier, there must not be any table 
identifiers in the form <table_name> equal to [<owner.]<result_table_name> , where 
owner is the current user. Each table identifier must differ from any other table 
identifier.

The validity range of the table identifiers is the entire QUERY specification within 
which the FROM TABLE specification is used. If column names are to be qualified within 
the query specification, table identifiers must be used for this purpose.

Reference names are essential for formulating JOIN conditions within a table. For 
example, FROM HOTEL, HOTEL X defines a reference name X for the second occurrence of 
the HOTEL table. Reference names are also necessary sometimes to formulate correlated 
subqueries. Similarly, a reference name is required if a column in the result of a 
QUERY expression can only be identified uniquely by specifying the reference name.

Number of underlying tables

If a from table specification denotes a base table, result table, or the result of a 
query expression, the number of tables underlying this from table specification is 
equal to 1.

If a from table specification denotes a complex view table, the number of tables 
underlying this from table specification is equal to 1.

If a from table specification denotes a view table that is not a complex view table, 
the number of underlying tables is equal to the number of tables underlying the FROM 
condition of the view table.

If a from table specification denotes a JOINED TABLE, the number of tables underlying 
this from table specification is equal to the total number of underlying tables of the 
FROM TABLE specifications contained in it.

QUERY expression (query_expression)

A FROM TABLE specification that contains a QUERY expression specifies a table 
identifier only if a reference name is specified.

If a FROM TABLE specification contains a QUERY expression, a result table is built 
that matches this QUERY expression. This result table obtains a system-internal name 
that collides neither with an unnamed nor a named result table. While the from 
condition is being processed, the result of the query expression is used in the same 
way as a named result table and is deleted implicitly after processing.

A table expression containing at least one OUTER JOIN indicator (see JOIN predicate) 
or OUTER JOIN TYPE (LEFT | RIGHT | FULL) (see joined_table) is subject to strict 
restrictions if it is to be based on more than two tables. For this reason, a QUERY 
expression is frequently required to formulate a QUERY specification that is to be 
based on at least three tables and in which at least one OUTER JOIN indicator is used 
in a JOIN predicate.

JOINED TABLE

A from table specification containing a JOINED TABLE ( joined_table) specifies the 
number of table identifiers that are specified by the FROM TABLE specifications it 
contains.


And    AS   is not allowed.

Elke
SAP Labs Berlin

> 
> I found nothing about that in the sapdb-docu, but on another page:
> http://aubit4gl.sourceforge.net/aubit4gldoc/manual/html/sqlcon
> vert.html
> 
> TABLE_ALIAS_AS
> 
>     Insert the word "as" before table alias names in a 'from' clause
>     eg:
>        from ..., table1 t1, ...  ->  from ..., table1 as t1, ...
> 
> but, when I try :
> 
> SELECT * FROM tablename AS aliasname
> 
> there comes an Error :
> 
> Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
> Syntax error or access violation;-3008 POS(26) Invalid 
> keyword or missing 
> delimiter.
> 
> 
> So, is there a way to use Table-alias names in SQL Statements ?
> 
> Regards,
> Danny
> 
> -- 
> Using M2, Opera's revolutionary e-mail client: 
http://www.opera.com/m2/
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to