472,125 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

select using LIKE where first character is a integer

hi,

i have some data in mysql in a column like this:
6.1.01 Financial Regulations
3.32.02 Academic Counseling

what iam selecting is select by letter A, B, C...Z. so my first char in
the column is always a integer, how can i select when the first few
characters are always a integer, i want to get rid of the integers and
run query on the word when selecting.

would greatly appreciate someone's help on this

Jul 3 '06 #1
2 9069

<co******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
hi,

i have some data in mysql in a column like this:
6.1.01 Financial Regulations
3.32.02 Academic Counseling

what iam selecting is select by letter A, B, C...Z. so my first char in
the column is always a integer, how can i select when the first few
characters are always a integer, i want to get rid of the integers and
run query on the word when selecting.

would greatly appreciate someone's help on this
Given these circumstances, it would probably be smarter to match on a more
complete string rather than just the first letter. You could use:
{fld} LIKE '%Financial %'
or
{fld} LIKE '%Academic %"

and this would get you past caring about the irregular leading numeric
digits.
OR
you might take advantage of the fact that the string you are looking for
begins just after the blank space " " that follows the number.

WHERE MID({fld}, LOCATE(' ', {fld})+1, 1) = 'A'

LOCATE() finds the first blank space and MID() shows you the string starting
with the first alpahabetic character that follows.

I like the first solution because it identifies the string more explicitly.
Thomas Bartkus
Jul 5 '06 #2
hy
try this

select * from barcode
where (SUBSTR(barcode, 1, 1) not between '0' and '9')
or (SUBSTR(barcode, 2, 1) not between '0' and '9')
or (SUBSTR(barcode, 3, 1) not between '0' and '9')
Jul 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gary | last post: by
8 posts views Thread by Mr. B | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.