|
Posted by Ivαn Sαnchez Ortega on 12/27/07 20:36
mantrid wrote:
> *****************************
> $qtransactions = "SELECT cgttransactions.aimlisted, cgtcompany.name,
> cgtcompany.code, cgttransactions_1.amount,cgttransactions.amount AS
> sellamount,cgttransactions_1.boughtsold,
First, let's make your SQL query a bit more legible. Remember that in PHP
you DON'T have to end the string on a line break. And any half-decent SQL
engine will accept query strings with line breaks and/or newlines.
$qtransactions = "SELECT
cgttransactions.aimlisted,
cgtcompany.name,
cgtcompany.code,
cgttransactions_1.amount,
cgttransactions.amount AS sellamount,
cgttransactions_1.boughtsold,
IF(cgttransactions.boughtsold=0,cgttransactions.selllinkid,cgttransactions.transactionid)
AS selllinkid,
cgttransactions_1.datetime,$price AS price,
cgttransactions.price AS sellprice,
cgttransactions.datetime AS selldatetime,
cgttransactions_1.stamp+cgttransactions_1.comm AS charges,
cgttransactions_1.stamp+cgttransactions_1.comm+
(cgttransactions_1.amount*$price) AS total,
IF(cgttransactions.bbprice IS NOT NULL,\"B&B\",NULL) AS bb,
(cgttransactions_1.amount*cgttransactions.price) -cgttransactions.comm AS
selltotal,
((cgttransactions_1.amount*cgttransactions.price) -cgttransactions.comm) -
(cgttransactions_1.stamp+cgttransactions_1.comm
+(cgttransactions_1.amount*$price)) AS profnloss,
$yrsheld AS yrsheld
FROM cgtcompany INNER JOIN (cgttransactions INNER JOIN cgttransactions AS
cgttransactions_1 ON cgttransactions.transactionid =
cgttransactions_1.selllinkid) ON cgtcompany.companyid =
cgttransactions.companyid
WHERE $filter AND cgttransactions.myvarid=$selcdacnt
ORDER BY
cgttransactions.datetime,
DATEDIFF(cgttransactions.datetime,cgttransactions_1.datetime) ";
Now, let me try to understand that...
--
----------------------------------
IvΓ‘n SΓ‘nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Luchar por la paz es como follar por la virginidad
[Back to original message]
|