473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 4266
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I've a template with some PHP code in it. I need to get the names of all the PHP commands, so I can import them and so I can make sure they are officially allowed (for security purposes, users are...
2
by: RootShell | last post by:
Dear All Im having some dificulty here: I found a great PHP code by Catalin Mihaila that reads a SRC (Sinclair Spectrum $SCREEN Image Format) and tranforms it into PNG format to show onscreen...
1
by: Jim Dawson | last post by:
I was writing a subroutine to extract fields from lines of text when I ran into an issue. I have reproduced this error on Perl 5.8 on AIX, 5.8 on Linux and 5.6 on Windows. ############### CUT...
2
by: Ari | last post by:
we have a strange problem with oracle dynamic sql method 4. when selecting a substr we expect to, and normally, receive from oracle in the describe select list (SELDSC) the length of the...
2
by: lawpoop | last post by:
Hey folks - I'm working on a spellchecking routine. The pspell libraries don't handle punctuation; I have to make a script a little smarter. I'm having a problem popping English posessive...
6
by: sks | last post by:
Hi, Here is a small program that is wrtten to simply use substr. When the second parameter in substr (length of the string to be extracted) is lesser than 0, the output is the entire string (I'm...
3
by: kocek | last post by:
Hi! If I create an index using function Substr (e.g.: create index on SUBSTR(afield, -2) ) then if I use the substr on the given field, with the given parameter in a select, but I do not type...
1
by: Chad | last post by:
I am having a problem with substr() working when I enter the third perimeter. I am working on a price monitoring project that will download data from Amazon.com. After is downloads the page, it...
5
by: bcaillet | last post by:
Hi all, A few weeks ago I posted a question about a potential defect in Oracle 11g. Today I have more details on the error. Please contact me if you are an Oracle Support engineer, I will like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.