471,090 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Substr return from select

Can I do this? Can't find any ref.

select substr(col1,1,3) from table ...
select col1[1,3] from table

The column contains ABC123, DEF456, etc
I want:
ABC
DEF

Thanks
Jul 20 '05 #1
2 4182
Cal Lidderdale wrote:
The column contains ABC123, DEF456, etc
I want:
ABC
DEF


See
http://dev.mysql.com/doc/mysql/en/String_functions.html

These should work:
SELECT SUBSTRING(myColumn FROM 1 FOR 3) ...
SELECT SUBSTRING(myColumn, 1, 3) ...
SELECT LEFT(myColumn, 3) ...

Regards,
Bill K.
Jul 20 '05 #2
Bill Karwin wrote:
Cal Lidderdale wrote:
The column contains ABC123, DEF456, etc
I want:
ABC
DEF

See
http://dev.mysql.com/doc/mysql/en/String_functions.html

These should work:
SELECT SUBSTRING(myColumn FROM 1 FOR 3) ...
SELECT SUBSTRING(myColumn, 1, 3) ...
SELECT LEFT(myColumn, 3) ...

Regards,
Bill K.


Ah, worked like a charm - I had tried SUBSTR (mind stuck in php)
substrING nailed it. Thanks
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by lawrence | last post: by
2 posts views Thread by RootShell | last post: by
1 post views Thread by Jim Dawson | last post: by
2 posts views Thread by lawpoop | last post: by
6 posts views Thread by sks | last post: by
3 posts views Thread by kocek | last post: by
1 post views Thread by Chad | 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.