|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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". |
|
#3
|
|||
|
|||
|
Darius - the FA thru FJ are text in the category field.
Cheers, Barry |
|
#4
|
|||
|
|||
|
Whats the meaning of:
Quote:
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. |
|
#5
|
|||
|
|||
|
Hi Darius,
Thanks for that - it works fine! Cheers, Barry |
|
#6
|
||||
|
||||
|
Alternatively use this query condition, which is more efficient :
Code:
Category LIKE 'F'+'[A-J]' DevQuote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Multiple WHERE statement? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|