This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
SELECT SUBSTR( country, 1, INSTR(country, '-',1) - 1) as whatever from table
Joined: Jun 08, 2007
Thankyou very much, that works very well. It extracts the string before the hyphen, however sometimes it returns null for String that do not have a hyphen. Is there any way to avaoid getting null in the result set. So that I only get non null values?
Many thanks once again.
Joined: Jan 24, 2006
use the NVL function :
SELECT NVL( SUBSTR( country, 1, INSTR(country, '-',1) - 1), country) as whatever from table