Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query criteria left blank to get all records

Status
Not open for further replies.

delorfra

Programmer
Mar 8, 2001
79
0
0
FR
In an ASP frontpage 2000 form, I want the query to return all records in the table if a criteria text box is left blank instead of looking for "Null".
 
Well its your SQL code

use the Like statement

"Select * From YourTable Where Yourfield Like '" & Somevalue & "'*"
Note in SQL server replace the Asterisk with a Percent

"Select * From YourTable Where Yourfield Like '" & Somevalue & "'%"

so if left blank it will return all or
Like "*"

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
I am doing something similar - I want to search using the Like statement; however, if I try to use the & * portion, the FP Results show no records found. Here's my working FP code:

SELECT * FROM Results
WHERE ((Results.PSN) Like '::pSN::')

Now, if I add the & *, here's what I have:
SELECT * FROM Results
WHERE ((Results.PSN) Like '::pSN::' & '*')

If I try the quotes in any other configuration, the Verify Query fails... any ideas?

Thanks,
Ken
 
SELECT * FROM Results
WHERE ((Results.PSN) Like '::pSN::*')

remember to use % with Oracle ..

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top