Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

Query question - can I return values for records not found?

This is a discussion on "Query question - can I return values for records not found?" within the Databases section. This forum, and the thread "Query question - can I return values for records not found? are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 20th, 2006, 21:33
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 248
Thanks: 6
Thanked 0 Times in 0 Posts
Query question - can I return values for records not found?

My database (MS SQL2K) is used primarily for the entry, tracking and reporting of (software) QA test results. This query is used to poulate a test matrix page - columns represent supported platforms, rows represent test cases. Each cell is a link to the data entry page where the test case and platform are prepopulated. (Also prepopulated - from a cookie - are test date, build, language, locale and QA engineer, so that only pass or fail+severity and defect # need to be entered.) Submit returns the user to the updated matrix page, which is populated by the query in question, here...

For each combination of test case and supported platform, I need one record to be returned - even if there's no data in the TestResults table for some combinations. If there is data I want the query to return TestCase, Platform, TestDate, Build, QAEngineer and Result for the most recent test result (using MAX statements for Build and TestDate) - BUT, for combinations of test case/platform that have not yet been tested, is there some way to tell the query to return a record with "UNTESTED" (or even NULL) values for each (or even the first) field in the record?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Jun 21st, 2006, 19:56
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,685
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Query question - can I return values for records not found?

How is the data stored?
What's your table structure?

You can achieve what you mentioned above if you do something like this:
SELECT {fields} FROM Software s RIGHT JOIN Test t {etc...}

RIGHT JOIN causes the query to return all records from the first table, even if there isn't a matching record on the second table.
__________________
Diego - Web-Developer & London SEO Expert
jQuery Plugins: Multiple File Upload, Star Rating, FCKEditor | NEW: XML to JSON
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 24th, 2006, 17:06
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Query question - can I return values for records not found?

Use a default.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jun 24th, 2006, 17:55
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,685
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Query question - can I return values for records not found?

a default specifies a value for a null field in a new record...
it's got nothing to do with selects.
no records = no fields (using defaults or not)
__________________
Diego - Web-Developer & London SEO Expert
jQuery Plugins: Multiple File Upload, Star Rating, FCKEditor | NEW: XML to JSON
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 11th, 2006, 01:38
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 248
Thanks: 6
Thanked 0 Times in 0 Posts
Re: Query question - can I return values for records not found?

Turns out what I needed was a cross join combined with a left outer join. Pretty complicated, but works beautifully in the end.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 21st, 2006, 12:39
Up'n'Coming Member
Join Date: Feb 2004
Location: Woodbridge, UK
Age: 27
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Query question - can I return values for records not found?

Sounds pretty inefficient for what you wanted to do, if you find it's slow or needs tweaking, post the query here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
query, question, return, values, records, found

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Negative values in divs (layout query) Bocaj Web Page Design 1 Mar 30th, 2008 10:48
Simple SQL Select Query Question MrQuestions Databases 7 Mar 21st, 2008 01:11
MYSQL/PHP Query question andrewlondon Databases 1 Sep 19th, 2007 12:26
check query results values kal PHP Forum 4 Apr 11th, 2007 16:30
displaying database values question riotman Classic ASP 4 Dec 8th, 2005 12:45


All times are GMT. The time now is 16:13.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8