[Typo3-dev] quoting SQL-identifiers
Martin Kutschker
martin.kutschker at no5pam.blackbox.net
Tue Apr 26 09:37:34 CEST 2005
"Rainer Kuhn" <kuhn at punkt.de> schrieb im Newsbeitrag
news:mailman.1250.1114428106.11564.typo3-dev at lists.netfielders.de...
> Martin Kutschker wrote:
>> SELECT
>> a.col1,b.col2 as x,func1(a.col3),vcol1,(SELECT vcol3 FROM t2 WHERE
>> id=b.col2)
>> FROM
>> a, y as b, (SELECT vcol1,vcol2 FROM TABLE t1 WHERE id=a.col4) as c
>> WHERE
>> b.col5=func2(vcol2) AND
>> a.col6 IN SELECT vcol4 FROM t3
>
> That's exactly what I did in my example project. But this doesn't help for
> tablenames (of a given database) using reserved words, does it?
Why? With quotes it can be written like this:
SELECT
"a"."col1",b."col2" as x,func1("a"."col3"),"vcol1",(SELECT "vcol3" FROM
"t2" WHERE "id"="b"."col2")
FROM
"a", "y" as b, (SELECT "vcol1","vcol2" FROM TABLE "t1" WHERE
"id"="a"."col4") as c
WHERE
"b"."col5"=func2("vcol2") AND
"a"."col6" IN SELECT "vcol4" FROM "t3"
Note that I did not quote the table and field aliases.
Now you can use any name for your identifiers. My example was only to show
that an SQL-statement can be complex. So automaigical quoting needs to know
SQL fairly well.
Masi
More information about the TYPO3-dev
mailing list