Unanswered: problem with query where column name is the same as a keyword
I am having trouble with the following query within my store procedure.
as you can see, i am making an union of 2 separate queries.
in the 2nd part of the union, i encounter a column in the database where the column name is the same as the keyword "desc"
is there a way which i can get around this, or is there any other way that i can sepecify the column? (excluding the possibility of using *)
CREATE PROCEDURE topcat.getTransHistory
DECLARE @phone_no varchar(255)
set @phone_no = (select top 1 phone_num from topcat.class_contact where _id = @contact_id)
select cast(trans_new.trans_date as varchar(50)) date,
cast(payment.date_paid as varchar(50)) datepaid,
when 'cheque' then trans_new.item_total
when 'cheque' then ''
from topcat.class_transaction trans_new left outer join topcat.class_payment payment on trans_new._id = payment.transaction_id
where trans_new.contact_id = @contact_id
select cast(trans_old.date as varchar(50)) "date",
cast(trans_old.datepaid as varchar(50)) "datepaid",
cast(trans_old.pledged as varchar(128)),
cast(trans_old.received as varchar(128)),
from topcat.MMTRANS$ trans_old
where phone = @phone_no