Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8088487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:06:19+00:00 2026-06-05T19:06:19+00:00

I have a table named datas and I’m executing a query like this: SELECT

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:06:21+00:00Added an answer on June 5, 2026 at 7:06 pm

    You can use SUBSTRING_INDEX. Like this:

    select linkurl as DOWNLOADURL,lastrevlevel as VERSION,
    code  as DESCRIPTION,created as RELEASEDATE,
    SUBSTRING_INDEX(name,'.',-1) as TYPE
    from datas where id in
    (select child_id from datas _datas 
    where parent_id=( select max(id) from datas 
    where code = 'AN4307SW'))
    

    EDIT

    If you see the docs on this function I think this will apply well to you requirements.

    Returns the substring from string str before count occurrences of the
    delimiter delim. If count is positive, everything to the left of the
    final delimiter (counting from the left) is returned. If count is
    negative, everything to the right of the final delimiter (counting
    from the right) is returned. SUBSTRING_INDEX() performs a
    case-sensitive match when searching for delim.

    This will also handle a case like this:

    select SUBSTRING_INDEX('Test.Document.doc','.',-1);
    

    EDIT2

    If you are using oracle. Please tag the question in the correct matter next time. There is no SUBSTRING_INDEX in oracle. But what I can see you can do this quite easy:

    SELECT SUBSTR('Test.Document.doc', INSTR('Test.Document.doc', '.',-1)) 
    FROM dual; 
    

    Full query like this:

    select linkurl as DOWNLOADURL,lastrevlevel as VERSION,
        code  as DESCRIPTION,created as RELEASEDATE,
        SUBSTR(name, INSTR(name, '.',-1))  as TYPE
        from datas where id in
        (select child_id from datas _datas 
        where parent_id=( select max(id) from datas 
        where code = 'AN4307SW'))
    

    Reference here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have a table named EMP,which looks like this.... EmpName |EmpBranchName |ApproverId| Anil
I have a table named visiting that looks like this: id | visitor_id |
I have a table named ticket. I am trying to query between two dates,
In ms-access database i have a table named tableA this table has a column
I have a table named table1 where datas are entered as below. slno scxid
Totally new to Cake. I have this table named Content and another one named
I have a table named tbl_course nad the data is like SID name DisplayOrder
I have a table named Info of this schema: int objectId; int time; int
I have a table td class named on that I would like to fade
I have this table named OrdersToCall Data types: All bigints, except for date which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.