Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks for creating this site - I expect to be visiting it often as I continue to try to grow my bag of tricks!..."

Geography

Where in the world do Tek-Tips members come from?
Gcox (Programmer)
28 Dec 00 22:44
I am using the Database Region Wizard in FrontPage 98 to set up a simple SQL statement.  I was hoping someone could give me a couple of examples using the "LIKE" syntax with a variable called varName.  One example I found suggested this:

SELECT * FROM tblAddress WHERE [Name] Like '%%%varName%%%'

But this returns all the records regardless of what is in varName, and I've tried several different variations and nothing works.

Guest (Visitor)
16 Feb 01 17:39
If the FP database handles SQL the way other databases do you should perform a select in this fashion:

SELECT * FROM tblAddress WHERE [Name] LIKE 'varName'

The % is a wildcard character to allow you to get results where the varName matches a portion of the table field.

For instance, if you have a field in your table called "Name" and one of the records with the field "Name" has the contents of "Gregory" and another record has "Greg" you can perform a select statement to pull both of these records using the % wildcard character in this way:

... WHERE [Name] LIKE 'Greg%'

This condition will pull all records that meet the criteria of having the first four letters of 'Greg' in the field [Name].  

You will have to be careful with some databases as they are case sensitive.  So 'GREG' and 'Greg' are not the same. You can alleviate this problem with a function called UPPER (may or may not be supported on the FP database).  

Select * from <tablename> where upper(Name) like(upper('varName'))

This statement will cast the field "Name" and the varName to upper case in order compare apples to apples.

As for your select statement, the '%%%varName%%%' will retrieve all records that contain varName within the field. This is because you specified the % on both sides of the input host variable.
Guest (Visitor)
16 Feb 01 17:43
I had one more thought about why all the records are being retrieved.  If your input host variable is blank, i.e. the data is not being retrieved from the application, you will probably get a match on almost every row in your table.

One way to test this is to put a name into the select statement rather than the input host variable and  peform the select statement.  It should return rows with that particular value.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close