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

SQL 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
How can I search for records with wilcard and limit them for those with 7 digits only. For example if I have these records in table1:
13035551212
1212555
140455512125
and I run this SQL statement:
select * from table1 where column1 like '1%%%%%%'

only record 1212555 should have been returned.

Can any one help me to correct the statement
 
VFP's implementation of SQL allows you to imbed VFP functions in a SQL SELECT statement. Try this:

SELECT * FROM Table1 ;
WHERE LEN(RTRIM(Column1)) = 7

Hope this helps -- WB
 
Adding to what I said above, if you are looking only for 7-character values that begin with "1", then try this:

SELECT * FROM Table1 ;
WHERE LEN(RTRIM(Column1)) = 7 ;
AND LEFT(Column1, 1) = '1'

Hope this helps -- WB
 
select * from table1 where column1 like "1%"
Walid Magd
Engwam@Hotmail.com
 
Not sure if it would help, but you can try SET EXACT ON.
 
HELLLO,
Example 1: (assumed myFDield1 is Character based)
=========
select * from table1 WHERE ;
LEN(ALLT(myField1)) = 7 and LEFT(myField1,1) = "1"

Example 2:
=========
** Select for myVariable presence in the Table
** No limit to length
select * from table1 WHERE myVaiable $ myField1

Example 3:
=========
select * from table1 WHERE ;
LEN(ALLT(myField1)) = 7 and ;
between(VALUE(LEFT(myField1,7)),1000000,1999999)

The above example should get you through



ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top