Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 May 21st, 2006, 11:18 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Help with !> and !< conditional syntax

My objective with this query is to get all the incident (osirReport tble) records that have not had a general comment (comments tble) or an action comment (action tble) in the last three months.

osirReport is the main table that shares a one to many relationship with both the comments and action tables (each incident may have multiple action and general comments)

Please note: The query does not error, it just returns no results. I am not sure if I haver used the:
!> (Not Greater Than)
and the:
!< (Not Less Than)
operators properly

SELECT distinct osirReport.osirId,osirReport.osirShipNum,osirRepor t.osirHRI,osirReport.osirOrId,osirReport.osirSigna lDateTime,osirReport.osirActId,osirReport.creation Date FROM ((osirReport
LEFT OUTER JOIN reportComments ON osirReport.osirID = reportComments.osirID)
LEFT OUTER JOIN action ON osirReport.osirID = action.acOsirID)
Where (osirReport.osirStatus=1) AND (osirReport.osirTypeId IN ( 2))
AND (
    ((reportComments.lastEdited !> '2/22/2006 12:00:00 AM') AND (reportComments.lastEdited !< '5/22/2006 12:00:00 AM'))
or ((action.acDate !> '2/22/2006 12:00:00 AM') AND (action.acDate !< '5/22/2006 12:00:00 AM'))
    )
ORDER BY osirReport.osirSignalDateTime desc;

TYIA


Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old May 31st, 2006, 04:30 AM
Authorized User
 
Join Date: May 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This query will look for records that have:

reportComments.lastEdited earlier than Feb 22
AND
reportComments.lastEdited later than May 22

The date value in that field cannot fill both of these requirements

Records with a date value of Feb. 21 do not fill the second requiremnt
Records with a date value of May 23 do not fill the first requiremnt

As such you will not get any results. You need to change your operator to OR.

SELECT distinct osirReport.osirId,osirReport.osirShipNum,osirRepor t.osirHRI,osirReport.osirOrId,osirReport.osirSigna lDateTime,osirReport.osirActId,osirReport.creation Date FROM ((osirReport
LEFT OUTER JOIN reportComments ON osirReport.osirID = reportComments.osirID)
LEFT OUTER JOIN action ON osirReport.osirID = action.acOsirID)
Where (osirReport.osirStatus=1) AND (osirReport.osirTypeId IN ( 2))
AND (
    ((reportComments.lastEdited !> '2/22/2006 12:00:00 AM') OR (reportComments.lastEdited !< '5/22/2006 12:00:00 AM'))
or ((action.acDate !> '2/22/2006 12:00:00 AM') OR (action.acDate !< '5/22/2006 12:00:00 AM'))
    )
ORDER BY osirReport.osirSignalDateTime desc;

 
Old May 31st, 2006, 08:13 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Thank you for your time.

I ended up reaching my objective using two queries instead of the desired one. yes one is inside a loop, mmmm not ideal. I will try your method and let you know. Thanking you...

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
syntax error?<%@ Import Namespace="System.Data" %> fjm9 ASP.NET 1.0 and 1.1 Basics 2 January 16th, 2007 11:51 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 05:22 PM





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