SQL Question

V

Vincent Choy

Can anybody know how to set alias after 'where'?
select 1 as A, 2 as B,A-B as C from tbl where =1
 
B

Brian

Vincent Choy said:
Can anybody know how to set alias after 'where'?
select 1 as A, 2 as B,A-B as C from tbl where =1


Don't use the alias in the WHERE clause, use the actual field name or
expression:

select Field1 as A, Field2 as B, Field1-Field2 as C from tbl where Field2 =
1
 
V

Vincent Choy

it' Great! Thanks Dunc

SELECT
A,
B,
A-B AS C
FROM
(SELECT
1 AS A,
2 AS B
FROM tbl
) MySubQuery
WHERE B = 1

it works fine! Now we can convert from access to mysql (without view
function) easily
 
Top