B
B
bender30002017-10-19 21:07:06
MySQL
bender3000, 2017-10-19 21:07:06

How to select a number from the data listed separated by commas?

I have a table dbo_scale with row scale where there is an entry 0,1,2,3,4,5,6,7,8 . And there is a table dbo_grade with a row finalgrade value 5 . I need to output a number from scale , which will be the fifth in a row, i.e. "4".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Wolf, 2017-10-19
@mannaro

finalgrade - 1:D

I
Immortal_pony, 2017-10-20
@Immortal_pony

SELECT 
  RIGHT(
    SUBSTRING_INDEX(`dbo_scale`.`scale`, ',', dbo_grade.`finalgrade`),
    LENGTH(dbo_grade.`finalgrade`)
  )
FROM 
  `dbo_scale`
  JOIN `dbo_grade`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question