I have a table named datas and I’m executing a query like this:
SELECT linkurl AS DOWNLOADURL,
lastrevlevel AS VERSION,
code AS DESCRIPTION,
created AS RELEASEDATE,
name AS TYPE
FROM datas
WHERE id IN (SELECT child_id
FROM datas _datas
WHERE parent_id = (SELECT Max(id)
FROM datas
WHERE code = 'AN4307SW'))
It returns results like this:
DOWNLOADURL VERSION DESCRIPTION RELEASEDATE TYPE
/artifacts/download.txt 2.0 images 25/6/12 download.txt
In the Type column I am geting name of the file. I need to get the file extension of the file name in the Type column. How can I achieve this?
Examples:
TYPE
.txt
.pdf
.xls
You can use
SUBSTRING_INDEX. Like this:EDIT
If you see the docs on this function I think this will apply well to you requirements.
This will also handle a case like this:
EDIT2
If you are using oracle. Please tag the question in the correct matter next time. There is no
SUBSTRING_INDEXin oracle. But what I can see you can do this quite easy:Full query like this:
Reference here