RE: [PHP-WIN] query php
| From: | Nold, Mark | Date: | Tue, 11 Jul 2000 00:55:38 +0000 |
| Subject: | RE: [PHP-WIN] query php | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-1005@lists.php.net to get a copy of this message | ||
----------------------------------------------------------------------------
-----------------
Disclaimer: The information contained in this email is intended only for the
use of the person(s) to whom it is addressed and may be confidential or
contain legally privileged information. If you are not the intended
recipient you are hereby notified that any perusal, use, distribution,
copying or disclosure is strictly prohibited. If you have received this
email in error please immediately advise us by return email at
postmaster@normandy.com.au and delete the email document without making a
copy.
----------------------------------------------------------------------------
-----------------
I typically find you can do single quotes in sql instead of escaped doubles;
$foo = "X";
$sql = "
SELECT
*
FROM
mytable
WHERE myfield = '$foo'
";
I find this is much more readable than all those nasty escaped double
quotes.
The other interesting point is some things seem OK in in Access via ODBC but
not directly in Access. I think a LIKE 'FOO%' is possible via ODBC but you
would have to do a LIKE 'FOO*' in MS Access itself.
Hope this helps somebody :)
mn
-----Original Message-----
From: Stas Trefilov [mailto:stas.t@cpstc.com]
Sent: Monday, July 10, 2000 3:25 PM
To: php-windows@lists.php.net
Subject: Re: [PHP-WIN] query php
Maurizio Piccolo wrote:
>
> Hi, everybody, i'm in trouble with a query'statemanet that I've to
> translate from Access to a string to put
> in odbc_exec().
>
> Here is the sql statement
>
> SELECT TitoliPerIndici.ISIN, Titoli.Titolo, TitoliPerIndici.Indice,
> Titoli.Settore, Titoli.Nazione, Titoli.Capitalizzazione,
>
Format([capitalizzazione]/DSum("[capitalizzazione]","qryIndiciCapitalizzazio
ni","[indice]='"
> & [Index] & "'")*100,"0.00") AS Peso
> FROM Titoli INNER JOIN (IndiciComit INNER JOIN TitoliPerIndici ON
> IndiciComit.Indice = TitoliPerIndici.Indice) ON Titoli.ISIN =
> TitoliPerIndici.ISIN
> WHERE (((TitoliPerIndici.Indice)=[Index]));
>
ODBC itself doesn't parse the statement you give it, it just passes it to
the database and gets back results. So if you used this statement in
Access, you can easily put it as an ODBC select statement. Just don't
forget to use slashes on quotes:
$sql = "SELECT TitoliPerIndici.ISIN, Titoli.Titolo,
TitoliPerIndici.Indice, Titoli.Settore, Titoli.Nazione,
Titoli.Capitalizzazione,
Format([capitalizzazione]/DSum(\"[capitalizzazione]\",
\"qryIndiciCapitalizzazioni\", \"[indice]='\" & [Index] &
\"'\")*100,
\"0.00\") AS Peso
FROM Titoli
INNER JOIN
(IndiciComit INNER JOIN TitoliPerIndici
ON IndiciComit.Indice = TitoliPerIndici.Indice)
ON Titoli.ISIN = TitoliPerIndici.ISIN
WHERE (((TitoliPerIndici.Indice)=[Index]))";
--
Stas Trefilov
Moscow Russia