Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem SQL Code.

Posted on 2006-11-22
4
Medium Priority
?
294 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

971 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