RE: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

2001-04-06 Thread Rif Kiamil

What type of database u using ?

Rif

 -Original Message-
From:   Paul Sinclair [mailto:[EMAIL PROTECTED]] 
Sent:   06 April 2001 16:25
To: CF-Talk
Subject:SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

I am trying to get a db output where a user selects an alphabetical range in
a form and then the sql selects all users in a db whose last names start
with one of the letters in that range. For example, on a form page the user
selects a range of a-f. I need to find all users whose last names start with
a letter in that range and output the results.

I think I recall a simple way to do this, but right now can't think of it.
Could anyone jog my memory for me?

Thanks,
Paul Sinclair
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

2001-04-06 Thread Aaron Cooper

try:


WHERE field LIKE 'a%' OR field LIKE 'b%'...


Aaron Cooper, BSc
Application Developer, Freeserve.com Plc
The Observatory, 36-41 Clerkenwell Close, London EC1R OAU
T: 0207 553 4992  M: 07799 191 589

-Original Message-
From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
Sent: 06 April 2001 16:25
To: CF-Talk
Subject: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.


I am trying to get a db output where a user selects an alphabetical range in
a form and then the sql selects all users in a db whose last names start
with one of the letters in that range. For example, on a form page the user
selects a range of a-f. I need to find all users whose last names start with
a letter in that range and output the results.

I think I recall a simple way to do this, but right now can't think of it.
Could anyone jog my memory for me?

Thanks,
Paul Sinclair
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

2001-04-06 Thread mherbene

If it will always be exactly one character, instead of wildcards I would do

select blah
fromblahtable
where   left(lastname, 1) in (#listqualify(form.selectbox_of_letters, "'")#)

you might have to use something other than left(lastname, 1) if your
database uses a different function for that.  Be sure to test with the max
number of letters as some DBs don't allow an IN list to be longer than some
magic number



-Original Message-
From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 06, 2001 11:25 AM
To: CF-Talk
Subject: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.


I am trying to get a db output where a user selects an alphabetical range in
a form and then the sql selects all users in a db whose last names start
with one of the letters in that range. For example, on a form page the user
selects a range of a-f. I need to find all users whose last names start with
a letter in that range and output the results.

I think I recall a simple way to do this, but right now can't think of it.
Could anyone jog my memory for me?

Thanks,
Paul Sinclair
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

2001-04-06 Thread Paul Sinclair

Rif,

It is an MSAccess db.

Paul



 -Original Message-
 From: Rif Kiamil [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 06, 2001 12:01 PM
 To: CF-Talk
 Subject: RE: SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.


 What type of database u using ?

 Rif

  -Original Message-
 From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
 Sent: 06 April 2001 16:25
 To:   CF-Talk
 Subject:  SQL LIKE statement: LIKE '%a'; LIKE '%b'; LIKE '%c', etc.

 I am trying to get a db output where a user selects an
 alphabetical range in
 a form and then the sql selects all users in a db whose last names start
 with one of the letters in that range. For example, on a form
 page the user
 selects a range of a-f. I need to find all users whose last names
 start with
 a letter in that range and output the results.

 I think I recall a simple way to do this, but right now can't think of it.
 Could anyone jog my memory for me?

 Thanks,
 Paul Sinclair

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists