Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2006, 10:11 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help...subquery problem

I have an issue wherein SQL won't return a result from a Select statement when there is only one result from a subquery.

The SQL statement in question is as follows;

SELECT * FROM Incidents WHERE (IncidentID IN SELECT IncidentID FROM Mitigation WHERE Mitigation_Activity = 'System/network configuration update')) ORDER BY IncidentID

If there is a more than one record in the Mitigation_Table, it works fine. However, if there is only one record in the Mitigation_Table, nothing is returned.

 
Old September 14th, 2006, 10:24 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops...sorry, missed the open paren at the beginning of the subquery when I typed it in, but it's there when I run the query.

 
Old September 14th, 2006, 10:41 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

In your scenario, when only 1 row exsists in the Mitagation table, does the id that is returned from your subquery exist in Incidents?

Try running your subquery as just a query with 1 row in your Mitigation table, get the incidentID and run your original query and replace the subquery with the id that is returned as opposed to using your subquery.

"The one language all programmers understand is profanity."
 
Old September 14th, 2006, 11:05 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks...Wow...quick response. I was just logging in to say I'd resolved it and as it turns, out with pretty much the same solution.

Thanks again!

 
Old September 14th, 2006, 11:45 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Glad you got it worked out.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Subquery debbiecoates SQL Server 2000 4 June 25th, 2008 03:49 AM
Subquery problem - help anyone? Scott B SQL Server 2000 4 September 26th, 2007 04:07 AM
PHP/MySQL Subquery Problem gfackler MySQL 1 April 18th, 2007 11:31 PM
Do i have to use a subquery, if yes then how? code_lover SQL Language 2 January 2nd, 2007 02:22 PM
SQL Select problem (subquery needed??) deian SQL Language 7 February 3rd, 2004 02:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.