0

I have this column called location in a table called raw_data. Each row have lots of varchar data separated by [, ]. Examples

Row 1 dusseldorf, kjsbdfygs4, Germany

Row 2 768768745h, kiev, Ukraine

Row 3 %%%%666, Accra, Ghana

Yes some make no sense. Im trying to select the last part of the string which is the country and display it. I tried using the substring index query and understand how it works but cant seem to understand how to apply it to a column.

2 Answers 2

1

You can use as per below-

SELECT SUBSTRING_INDEX(my_column,',',-1) FROM raw_data;

Note: If you need 1st part then use only 1 instead of -1.

Sign up to request clarification or add additional context in comments.

Comments

0

use like this

SELECT SUBSTRING_INDEX(location ,',',2);  

go to below link for explanation

http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.