Solved

How to delete a space and the string after space, in a entire column ?

Posted on 2013-05-23
4
532 Views
Last Modified: 2013-05-23
Helo, could you help me with the next issue?

I need delete a first space and the string after their space, in a entire column

Example with just a row:

select pointname
from from_ap
where pointname like 'AER_4L_SA6____I%';

Open in new window

say:
AER_4L_SA6____I Corriente Sal.06 33kV

Open in new window

I want:
AER_4L_SA6____I

Open in new window

It is possible to do using SUBSTR, INSTR or regular expressions, in every column 'pointname'?

Thank in advanced!
0
Comment
Question by:carlino70
  • 2
4 Comments
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 39191010
You can do it with regular expressions but they are expensive.

Given something this simple I would go with:
substr(pointname,1,instr(pointname,' ')-1)
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39191015
If you are interested, here is the regex version:
regexp_substr(pointname,'^[^ ]*')
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 39191047
if you use the substr/instr method, you have to be sure there really is a space if so, then the first post will work.

if the string might not have a space in it and you'd like to return the entire string then either use the regexp_substr method  or


case when instr(pointname,' ') = 0 then pointname else substr(pointname,1,instr(pointname,' ')-1)  end

or slightly smaller syntax using decode

decode(instr(pointname,' ') ,0, pointname, substr(pointname,1,instr(pointname,' ')-1) )
0
 

Author Closing Comment

by:carlino70
ID: 39191531
It works.

Thanks to both!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Include a logo in email body using Oracle utl_mail 11 33
form builder not starting 3 41
Foxpro errors 4 35
How to create a unique rule restriction on a table for two fields 16 87
This article describes some very basic things about SQL Server filegroups.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question