sql query with string operation

i want to write sql query with string operation...

In filed Got First name then space last name.....
i want to select only first name and differenciate by space.
In sql only
Thanks
ramChand123Asked:
Who is Participating?
 
flow01Connect With a Mentor Commented:
Is this of any help ?
http://www.volny.cz/iprenosil/interbase/ip_ib_code_string.htm#_code_strpos
Position of substring function in SP

create function POS in the example
SELECT SUBSTRING(name,POS(' ')-1) FROM table
0
 
flow01Commented:
select substr(name,1,instr(name,' ') - 1) first_name from table

what should happen if there is no space ?

select decode instr(name,' '), 0,'No firstname',
                                                   substr(name,1,instr(name,' ') - 1) )  first_name from table
0
 
ramChand123Author Commented:
in one filed i have

"abc def"

i want only abc only.......
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ramChand123Author Commented:
i m using firebird
0
 
ramChand123Author Commented:
in firebird instr and substr is not working
0
 
flow01Commented:
I don't know of firebird , can you execute the shown sql ? (modified for your table)
0
 
ramChand123Author Commented:
any firebird expert ?
0
 
flow01Commented:
substr infirebird =
SUBSTRING(<str> FROM startpos [FOR length])

an equivalent of instr I can't find fast but maybe you know a function firebird to determine the position of a character in a string  (thats what instr does)
0
 
reb73Commented:
Try -

SELECT SUBSTRING(name,STRPOS(' ')-1) FROM table
0
 
ramChand123Author Commented:
sorry but strpos is not working.....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.