|
-
Dec 22nd, 1999, 10:53 AM
#1
Thread Starter
Addicted Member
On a form I have a textbox called "FirstName". If a user enters the letter "A". How would I create an SQL statement that would list all the recods that begin with the letter "A"
------------------
OmarSwan
Student
[email protected]
http://omarswan.da.ru/
"Jesus is Lord"
-
Dec 22nd, 1999, 11:33 AM
#2
Guru
If you are using an MS Access database:
Select * from MyTable where FirstName LIKE 'A*'
or with a VB textbox
Select * from MyTable where FirstName LIKE '" & text1.text & "*'"
If you are not using Access, and are using a different DB (like SQL Server) use a percent sign at the end of your like parameter instead of an asterisk
Select * from MyTable where FirstName LIKE 'A%'
Tom
-
Dec 24th, 1999, 04:59 AM
#3
Member
These two predicates are used for matching strings simliar to the equal (=) conditional. The two wild characters used with SQL are .
% - matches any string
* - matches any character
i.e.
Assume that we want to find all the FirstName in the database, but are not sure of the spelling used. The 'A' can be used with the % wildcard for the search.
Do what Clunietp uses.
Select * from MyTable where FirstName LIKE 'A*'
Select * from MyTable where FirstName LIKE '" & Text1.Text & "*'"
Select * from MyTable where FirstName LIKE 'A%'
------------------
Ruchi
[email protected]
-
Dec 24th, 1999, 02:34 PM
#4
Guru
Ruchi
* does not match a single character, in Jet-SQL, the ? (question mark) is the placeholder for the single character. The * in jet sql matches any string length (zero or more)
The % (percent sign) in T-SQL (SQL Server) acts as the same as the * in jet SQL, while the _ (underscore) acts as the ? (question mark) in Jet-SQl, being the single character placeholder
I'm not sure if you meant it this way, but I got a little confused on what you were trying to say, and wanted to clarify
Thanks
Tom
-
Dec 27th, 1999, 01:52 PM
#5
Member
Clunietp,
You are absolutely right!
Ruchi
[This message has been edited by Ruchi (edited 12-28-1999).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|