ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

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 Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 8th, 2004, 10:57 AM
myhomie myhomie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 20 myhomie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow Searching with incomplete entries

I am wondering how I would implement a search when a field from a form is filled in incompletely. Say, when searching for a first or last name, the person only puts in the first two letters of that last name. How would I do SQL/Cold Fusion code so that the search would display/give back the names that match up based on the one/two or whatever letters the person entered in the form (if it was not complete)???
Thanks...ps my code works so far if you enter the whole thing correctly:

SELECT * FROM ALUMNA
WHERE 0=0
<cfif Len(Form.fname)>AND FIRSTNAME='#Form.fname#'</cfif>
<cfif Len(Form.lname)>AND LASTNAME='#Form.lname#'</cfif>

Thanks a bunch - have a great day!

Reply With Quote
  #2  
Old October 8th, 2004, 11:43 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You want to try the LIKE operator in your WHERE clause:

select *
from mytable
where lastname like '%form.lastname%'

Now myhomie, I mentioned this in your previous post. The questions you are asking are covered in the first 50 pages of any SQL book. This is extremely basic stuff. Before you ask any further questions I urge you to read a basic SQL book. I have to say that I'm not going to answer many more of these types of questions because, as I said, they are covered over and over in every SQL book on the market. Try Ben Forta's to start with:

http://www.amazon.com/exec/obidos/t...il/-/0672325675
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old October 8th, 2004, 02:26 PM
myhomie myhomie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 20 myhomie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
You want to try the LIKE operator in your WHERE clause:

select *
from mytable
where lastname like '%form.lastname%'

Now myhomie, I mentioned this in your previous post. The questions you are asking are covered in the first 50 pages of any SQL book. This is extremely basic stuff. Before you ask any further questions I urge you to read a basic SQL book. I have to say that I'm not going to answer many more of these types of questions because, as I said, they are covered over and over in every SQL book on the market. Try Ben Forta's to start with:

http://www.amazon.com/exec/obidos/t...il/-/0672325675


Thanks for your help.

Reply With Quote
  #4  
Old October 8th, 2004, 02:45 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You're welcome man. I'm not trying to be harsh, I'm just trying to let you know that in the long run if you don't learn the basics the only person you're hurting is yourself.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Searching with incomplete entries


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 4 hosted by Hostway