473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4291
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(myCol umn FROM 1 FOR 3) ...
SELECT SUBSTRING(myCol umn, 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(myCol umn FROM 1 FOR 3) ...
SELECT SUBSTRING(myCol umn, 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
3395
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 only allowed to use officially allowed commands). I'm using the following class method. substr is not working as I expect. When I echo out $location1 and $location2 I get 8287 and 8306 which are correct answers for the first PHP command. But when...
2
2488
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 by the PHP gd2 Library. The problem is that im trying to translate the 'fread' structure into a MySQL blob reading, as follows:
1
1977
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 HERE ############### #!/usr/bin/perl -w my @list = ("field1 field2 field3"); sub stripws($)
2
10448
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 substring. For example, when performing "select substr(table_name,1,5) from cat" we expect to receive the length of 5. This indeed happens on our aix machine, but on a customer's hp machine we receive the length 30 (the length of table_name.) We have also...
2
2926
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 endings off of strings. I thought that this little snipper would do the job: <code> if ( substr( $word, -2) == "\'s" ) {
6
6022
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 using gcc 4.1.0) My questions are : 1. Is this behaviour correct ? ( Or should this case be an exception?) 2. If it is correct, what is the idea behind this behaviour ?
3
3894
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 directly the parameter value -2 but it is dynamically calculated (e.g.: WHERE SUBSTR(afield, anotherfield * 2) = '01'
1
2365
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 strips the tags, then is supposed to give me only the price data by using substr(). Below is my code: <?php include("LIB_http.php"); include("LIB_parse.php");
5
5056
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 to follow up directly. The first Query 1 returns the correct value SELECT SUM(t.debitmst) 270 FROM (
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.