Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem SQL Code.

Posted on 2006-11-22
4
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

670 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