This topic is locked
[SOLVED]

 SQL QUERY

4/28/2011 3:37:24 AM
PHPRunner General questions
S
swanside author

I have made a report from a table.

If I use this query

SELECT

R001,

customerPK,

locationPK,

R438,

R021,

R077,

R078,

PIK010,

R025,

R033,

R034,

R035,

(SELECT `R035`-`R034`) AS DROP,

R037,

R038,

R039,

R040,

R041,

R042,

Job_No,

JobSheet

FROM report

WHERE (JobSheet ='Gas Guard')

ORDER BY R438



I get a can not retreive colums information. You have an error in your sql syntax and check the right syntax to use around DROP.

But this works

SELECT

R001,

customerPK,

locationPK,

R438,

R021,

R077,

R078,

PIK010,

R025,

R033,

R034,

R035,

R037,

R038,

R039,

R040,

R041,

R042,

Job_No,

JobSheet

FROM report

WHERE (JobSheet ='Gas Guard')

ORDER BY R438


I want to be able to display the value of field R035 - R034 as a seperate field?

Cheers

Paul.

Sergey Kornilov admin 4/28/2011

Drop SELECT

`R035`-`R034` AS DROP,
S
swanside author 4/28/2011



Drop SELECT

`R035`-`R034` AS DROP,



Thanks,

But, That still didnt work.

Now, If I change it to ]R035-R034 AS Diff
That works, must be the word DROP as in DROP the database?
Thanks

Paul.

J
joker 4/28/2011



Thanks,

But, That still didnt work.

Now, If I change it to ]R035-R034 AS Diff
That works, must be the word DROP as in DROP the database?
Thanks

Paul.


I think DROP is one of the reserved words that causes problems if you try to use it as a column name. Same thing trying to name a column "SELECT". Try naming it DROPX or something along those lines.

S
swanside author 4/28/2011



I think DROP is one of the reserved words that causes problems if you try to use it as a column name. Same thing trying to name a column "SELECT". Try naming it DROPX or something along those lines.


I did Diff

Now, If I change it to ]`R035`-`R034` AS Diff



Works great.