If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SELECT FROM, trouble with the WHERE bit

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-05, 13:13
goplanit goplanit is offline
Registered User
 
Join Date: Mar 2005
Posts: 3
SELECT FROM, trouble with the WHERE bit

HI,

I'm sure this must be simple but I just can't get the syntax right.

sql="select * FROM products INNER JOIN (orderitems INNER JOIN orders ON orders.orderid=orderitems.orderid) ON products.productid=orderitems.productid where ostatus<>'Cancelled' and custid=" & valid_sql(session("custid")) & " order by orders.orderid"

That works OK but I want ostatus<>'Cancelled OR 'Uncompleted'

Anyone?
Reply With Quote
  #2 (permalink)  
Old 03-03-05, 14:08
DMWCincy DMWCincy is offline
Registered User
 
Join Date: May 2004
Posts: 125
you can do this in a few different ways.

1: ostatus<>'Cancelled' OR ostatus<> 'Uncompleted'
2: ostatus not in ('Cancelled', 'Uncompleted')

HTH
Reply With Quote
  #3 (permalink)  
Old 03-03-05, 14:53
goplanit goplanit is offline
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks

Method 1 doesn't work, I had tried that it just goes into a loop.
Method 2 works fine though.
Reply With Quote
  #4 (permalink)  
Old 03-03-05, 21:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
to get 1 to work....
Code:
1: ostatus<>'Cancelled' OR ostatus<> 'Uncompleted'
should be
Code:
1: ostatus<>'Cancelled' AND ostatus<> 'Uncompleted'
status must not = Cancelled and Status must not = Uncompleted. if it is or then the Cancelled's <> Uncompleted so they pass and visa versa.
Reply With Quote
  #5 (permalink)  
Old 03-04-05, 12:54
DMWCincy DMWCincy is offline
Registered User
 
Join Date: May 2004
Posts: 125
Thanks rokslide...that was my bad.
Reply With Quote
  #6 (permalink)  
Old 03-04-05, 19:45
goplanit goplanit is offline
Registered User
 
Join Date: Mar 2005
Posts: 3
Quote:
1: ostatus<>'Cancelled' AND ostatus<> 'Uncompleted'
Thats not correct, there are no records that are both cancelled and uncompleted, they are either one or the other, or something else. If I use that it returns all records.
Reply With Quote
  #7 (permalink)  
Old 03-06-05, 16:48
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Code:
1: ostatus<>'Cancelled' AND ostatus<> 'Uncompleted'
using the above should return those that are (as you put it) "something else". If it is returning everything then I would be tempted to suggest that there is a flaw somewhere else in your query. It's possible that you need to wrap this section in brackets or something else, it really depends on what is happening...
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On