R
R
repeat2015-11-13 00:11:12
MySQL
repeat, 2015-11-13 00:11:12

MySQL query, how to discard the last word in a string?

I didn’t find a function on the run, I came up with a monster

SELECT REVERSE(SUBSTR(REVERSE(trackname_full), POSITION(' ' IN REVERSE(trackname_full))+1)) as alt ...

You can do this in PHP, but I wonder what MySQL has for this?
How much this request "brake"?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Марат, 2015-11-13
@repeat

Можно и другим "монстром" :-)

select substring_index(st1, ' ', length(st1) - length(replace(st1,' ',''))) as alt ....

Равшан Абдулаев, 2015-11-13
@ravshanium

а если перед словом не пробел, а другой разделяющий символ?
может поможет:www.mysql.ru/docs/man/Regexp.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question