TicTacTech.net Forums
Another SQL question - Printable Version

+- TicTacTech.net Forums (https://tictactech.net/forum)
+-- Forum: Technology (https://tictactech.net/forum/forumdisplay.php?fid=4)
+--- Forum: Ask ChatGPT (https://tictactech.net/forum/forumdisplay.php?fid=9)
+--- Thread: Another SQL question (/showthread.php?tid=23)



Another SQL question - andrew - 10-31-2023

A SQL column, street, in the address table, has values with multiple lines that are separated with carriage returns. Write me a SQL query to return only the last line of the street field, ignoring all previous lines.


Another SQL question - rpgking - 10-31-2023

SELECT SUBSTRING_INDEX(street, '\r', -1) FROM address;


RE: Another SQL question - andrew - 11-01-2023

(10-31-2023, 05:26 PM)rpgking Wrote: SELECT SUBSTRING_INDEX(street, '\r', -1) FROM address;

Doesn't work in SQL 2016. Substring_index is not a valid function. I guess I should have specified sql 2016.  :0 Rock On