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.
|
|
|
|
|
![]() |
||
Query question - can I return values for records not found?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
||||
|
||||
|
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)
|
|
#3
|
||||
|
||||
|
Re: Query question - can I return values for records not found?
Use a default.
|
|
#4
|
||||
|
||||
|
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)
|
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
|||
|
|||
|
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.
|
![]() |
| Tags |
| query, question, return, values, records, found |
| Thread Tools | |
|
|
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 |