Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2006, 11:18 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #2 (permalink)  
Old May 31st, 2006, 04:30 AM
Authorized User
 
Join Date: May 2006
Location: , , .
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;

Reply With Quote
  #3 (permalink)  
Old May 31st, 2006, 08:13 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:19 PM.


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