navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Query

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Query
Page: [1]
 
Guest


 
Query - 3/8/2001 20:55:00   
Here is a SQL query i am running in the DRW

SELECT * FROM table
WHERE (lname = '::lname::' or ID = '::id::')

This query works fine however it doesnt give me desired results. What i am looking to do is to be able to enter the LName and receive results, or enter both LName and ID and get filtered results where only the criteria entered in both fields is returned. Currently if i enter Smith in LNAME and 227 in ID i get returned everyone named smith and everyone with ID 227. I want just the SMITHS with ID 227. Or If I just put in 227 in ID and leave LNAME field blank I just want ID 227 returned. Basically i want to add more fields to search on and just have values returned matching the criteria I enterd into the filed (Note: some search fileds may be left blank and Id like to search on the remaining search fields) Thanks

Elecia

 

Posts: 68
From: orlando
Status: offline

 
RE: Query - 3/8/2001 23:25:00   
I'm sure that there are other solutions to your problem and this may not be the best one but it will do what you want.

You could set the default value of each of your text boxes to * or % if forget now which one works as a wild card in FrontPage. Use validation on the text boxes so that they always a have some value (or a wild card). Then you can add as many fields as you like using and in SQL statement.

SELECT * FROM table
WHERE (lname = '::lname::' and ID = '::id::'and state = '::state::' )

So if the user entered only a last name of smiths and wild cards for the other 2 fields they would get all the smiths. If they entered a last name of smith and the state of Florida they would get all smiths in florida and so on.

EE


(in reply to Guest)
Vince from Spain

 

Posts: 658
From: Madrid Spain
Status: offline

 
RE: Query - 3/9/2001 20:12:00   
Here's another idea . . . .

SELECT * FROM table
WHERE (lname = '::lname::' OR '::lname::'='') AND (ID = '::id::' OR '::id::'='')

So if a field is blank it matches the '::field::'='' part of the statment, which would yield TRUE . . . well, I'm sure you get it anyway ;)

You can just extend it by adding for instance . . .

SELECT * FROM table
WHERE (lname = '::lname::' OR '::lname::'='') AND (ID = '::id::' OR '::id::'='') AND (otherfield='::otherinput::' OR '::otherinput::'='')

All the best

Vince

------------------
Internet Business Solutions S.L.(Spain)


(in reply to Guest)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Query
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts