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

like operator in select statement

Status
Not open for further replies.

EKC

Technical User
Jan 13, 2001
43
CA
Hi ,

Select field1,field2 from Table1 where field1 like "A%" gives me all records in field1 that start with A
Field2 is number.If I want all numbers starting with 9 statement like "9%" doesn't work.
How to select all records(field2)that starts with 9?
Thanks
 
assuming the field is numeric a value...
WHERE LEFT(STR(Field1),1)="9"
or
WHERE ROUND(Field1,0) = 9 &&depends on numeric format
or
WHERE ROUND(Field1,2) = 0.09 &&depends on numeric format

if it is a character field already drop the STR() funtion.

-Pete
 
Since you appear to be fond of the LIKE operator:

WHERE TRANSFORM(field2) LIKE '9%'

If you anticipate your table having many records, you might want to consider creating an index on TRANSFORM(field2). Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Hi my friend,
Try this
Code:
*// Name is your string field, number is numeric field
lcForCond=[LIKE("9*",ALLT(STR(number)))]
SELECT name,number FROM table1 WHERE name LIKE "A%" AND &lcForCond
Thanks, Walid Magd
Engwam@Hotmail.com
 
I don't know why my for condition look like this after I post it, anyways it is
lcForCond=[LIKE("9*",ALLT(STR(number)))]
Walid Magd
Engwam@Hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top