setting variable in query

J

Joey Martin

I have a sql query that runs on my asp page.

select
contactname,contactnumber,contactnumber1,contactemail,address,city,state
,zip,type,sqft,0,bedrooms,baths,lotsize,acreage,garage,comments,price,0,
0,county from table1 where active='Y'

I need HASPHOTO to equal 1 if hasphoto <> 0 and HASPHOTO=0 when
hasphoto=0. Make sense? HASPHOTO usually equals a number, but in this
case, I want it to equal a 1 or 0 because I am exporting this to a CSV
file. I know how to do everything else, just not this part.

Thanks in advance.
 
B

Bob Barrows [MVP]

Joey said:
I have a sql query that runs on my asp page.

select
contactname,contactnumber,contactnumber1,contactemail,address,city,state
,zip,type,sqft,0,bedrooms,baths,lotsize,acreage,garage,comments,price,0,
0,county from table1 where active='Y'

I need HASPHOTO to equal 1 if hasphoto <> 0 and HASPHOTO=0 when
hasphoto=0. Make sense?

Not really. Is hasphoto a column in your table? What is its datatype?
HASPHOTO usually equals a number, but in this
case, I want it to equal a 1 or 0 because I am exporting this to a CSV
file. I know how to do everything else, just not this part.

Thanks in advance.

What database? Type and version, please.

Bob Barrows
 
J

Joey Martin

This is a SQL 2K server. HASPHOTOS is an int field. It is one of the
columns in my table.
 
B

Bob Barrows [MVP]

Joey said:
This is a SQL 2K server. HASPHOTOS is an int field. It is one of the
columns in my table.

SELECT ...,
CASE HASPHOTOS WHEN 0 THEN 0 ELSE 1 END [HASPHOTOS]
....

HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top