main logo
Subject: Re: SELECT the right sequence?
Author: Francois Van Lerberghe
Posted: 2002/05/30 06:57:00
 
View Entire Thread
New Search


Luca Porfiri wrote :
> =

> Hy all!
> =

> Could someone help me to understand the meaning?
> =

> This is the structure of sql string:
> =

> SELECT *
> =

> FROM table_1, table_2
> =

> WHERE
> =

> field_1.table_2 =3D field_2.table_1
> AND
> field_2.table_2 =3D "y"
> AND
> field_1.table_1 =3D "x"
> AND
> field_3.table_1 =3D "z"
> =

> it will search and find as the last query didn't exist. alias it consid=
ers
> anly the first statement after searching in table_2
> =

> What's the rule?

First, you must write :
tableName.fieldName
and not
fieldName.tableName

Next, the order is :

1. SELECT
2. fieldName list
3. FROM
4. tableName list

Followed optionnaly by:
5. WHERE
6. LinkConditions (if many tables)
7. SearchConditions

8. ORDER BY
9. fieldName [DESC]

The LinkConditions may be in any order I think.
The SearchConditions must be grouped by table (within parenthesis if
many conditions for a table) :

SELECT * =

FROM table_1, table_2
WHERE table_2.field_1 =3D table_1.field_2
AND
table_2.field_2 =3D "y"
AND
(table_1.field_1 =3D "x" AND table_2.field_3 =3D "z")

Best regards.

Fran=E7ois Van Lerberghe
Thier Monty, 15A
B-4570 Marchin
Belgique
 
©2002 Francois Van Lerberghe
<-- Prior Message New Search Next Message -->