Solved

Problem SQL Code.

Posted on 2006-11-22
4
232 Views
Last Modified: 2006-11-22
Hi All.

We have a website using SQL (And we are new to SQL in web sites......)

We wish to display a summary of items from a given database table. Our current code (THAT WORKS FINE) looks like this:

<%
SQL="SELECT Distinct City FROM Listings ORDER BY City ASC"
set rs=conn.execute(SQL)
do while not rs.eof
Total = conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"'")%>

We have a variable in the table - STATUS - and this is used to determine if the property is ON or OFF the market - ON and you can view the details in the detail view - OFF - you know....

What we would like is for the 'display summary' to show only the properties that are ON the market - thereby our query needs to include an additional opperand.

we have tried the following:

Total = conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"'") AND (Status="ON"))%>

but does not work.

Can anyone help us please.

Many thanks
Andy.
0
Comment
Question by:AndyKeen
  • 3
4 Comments
 
LVL 23

Expert Comment

by:adathelad
ID: 17994274
conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"' AND Status='ON'"
0
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
ID: 17994277
Sorry, missed the closing bracket:
conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"' AND Status='ON'")
0
 
LVL 1

Author Comment

by:AndyKeen
ID: 17994293
What can I say - absolutely spot on - thank you.

Points are yours.


Regards
Andy.
0
 
LVL 23

Expert Comment

by:adathelad
ID: 17994329
No problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now