×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

like operator in select statement

like operator in select statement

like operator in select statement

(OP)
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

RE: like operator in select statement

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

RE: like operator in select statement

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

RE: like operator in select statement

Hi my friend,
Try this

*// 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

RE: like operator in select statement

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login


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