Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old November 30th, 2004, 07:21 AM
bazzanoid bazzanoid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 21 bazzanoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 41 m 42 sec
Reputation Power: 0
Question Multiple WHERE statement?

Hi,

I'm developing a new e-commerce site for our company, and for the most part there's not been any problems with using the WHERE statement to pull records out of the db.

However, for one of the pages i need to pull more than one query on a single search. The single search i am doing is as follows:

strSQL = "SELECT ProductID, ProductName, Category, Supplier, UnitPrice, N_Disp " _
& "FROM Products " _
& "WHERE Supplier LIKE 'Baumatic' AND Category LIKE 'FA' " _
& "ORDER BY ProductName;"

What i need to do is display in the same query all other 'Baumatic' products with categories FA - FJ.

Any ideas how i can do this, short of a VERY long WHERE line, which repeats the same thing over and over?

Thanks,

Barry

Reply With Quote
  #2  
Old November 30th, 2004, 09:48 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 4
Why do you use LIKE, is FA part of a text in the category field?, if not this may work

strSQL = "SELECT ProductID, ProductName, Category, Supplier, UnitPrice, N_Disp " _
& "FROM Products " _
& "WHERE Supplier LIKE 'Baumatic' AND Category in ('FA','FB','FC','FD','FE','FF','FG','FH','FI','FJ' ) " _
& "ORDER BY ProductName;"

how to do it shorter (it already short)?

You can use "Select * from products where supplier='Baumatic' and Category in ('FA','FB','FC','FD','FE','FF','FG','FH','FI','FJ' ) ORDER BY ProductName".

Reply With Quote
  #3  
Old December 1st, 2004, 05:24 AM
bazzanoid bazzanoid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 21 bazzanoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 41 m 42 sec
Reputation Power: 0
Darius - the FA thru FJ are text in the category field.


Cheers,

Barry

Reply With Quote
  #4  
Old December 1st, 2004, 08:21 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 4
Whats the meaning of:
Quote:
Originally Posted by bazzanoid
Darius - the FA thru FJ are text in the category field.

1-FA tru FJ is part of a text in Category field?
2-FA tru FJ are a text in Category filed?

If the second, all is OK.

Reply With Quote
  #5  
Old December 2nd, 2004, 03:04 AM
bazzanoid bazzanoid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 21 bazzanoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 41 m 42 sec
Reputation Power: 0
Hi Darius,


Thanks for that - it works fine!

Cheers,

Barry

Reply With Quote
  #6  
Old December 6th, 2004, 05:52 AM
dev77's Avatar
dev77 dev77 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: On d Earth ofcourse..!!
Posts: 439 dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 15 h 59 m 40 sec
Reputation Power: 309
Thumbs up Alternative query

Alternatively use this query condition, which is more efficient :

Code:
Category LIKE 'F'+'[A-J]'


Dev


Quote:
Originally Posted by bazzanoid
Hi,

I'm developing a new e-commerce site for our company, and for the most part there's not been any problems with using the WHERE statement to pull records out of the db.

However, for one of the pages i need to pull more than one query on a single search. The single search i am doing is as follows:

strSQL = "SELECT ProductID, ProductName, Category, Supplier, UnitPrice, N_Disp " _
& "FROM Products " _
& "WHERE Supplier LIKE 'Baumatic' AND Category LIKE 'FA' " _
& "ORDER BY ProductName;"

What i need to do is display in the same query all other 'Baumatic' products with categories FA - FJ.

Any ideas how i can do this, short of a VERY long WHERE line, which repeats the same thing over and over?

Thanks,

Barry

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Multiple WHERE statement?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway