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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wildcard search without LIKE? 1

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I am trying to write an SQL statement using a wildcard in the search criteria without using LIKE. Here's my dilemma:
The table structure (which is NOT MY DESIGN) has the Defendant's Name as ONE field (LAST FIRST M) - BAD CALL from my point of view, but that's what I have to deal with. So, now I am trying to do a search by name and I'd like to be able to do something like:

WHERE DEFNAM = 'SMIT*'

which would return only those rows that start with SMIT instead of using LIKE, which would also return

JONES SMITTY

Is there a way to do this? I am using an AS400 backend, programming in Delphi, but figured this was the best forum to get SQL syntax information.

Thanks for any insight!



Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Hi Leslie,

I think that you have to use like operator. But i am sure that you will get what you want by using the like operator properly.

e.g.

starting with 'smit' ---- WHERE defnam like 'smit%'
ending with 'smit' ---- WHERE defnam like '%smit'
containing 'smit' ---- WHERE defnam like '%smit%'

and some other permutation combination also.

Let us know if does not solve your query.


---
Raj

 
I don't know if Transact-SQL syntax will work for you, but that's what Microsoft SQL Server uses and what this forum is for.

Using = probably won't work. It'll look for SMIT*, which isn't what you want.

Use LIKE.


-SQLBill
 
Thanks Raj, worked like a charm, I had always used LIKE with both '%something%' and didn't realize you could only use one!!

Thanks!
Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top