Hi, I how can i get the middle name of this string inside the query
table1(names)
JONY,KENTH L & PSY
BOB,NNETH BOSS
RALF,BENTH & MARIA MORIS
So, inside my query i want to get the middle name of those fields, that are L for the first row and BOSS for the second. the first row have & that indicates there is another name there, so the middle name is L. And also get the first name of the second person if appears after the & character.
how I can do this query:
select substring(********* from table1
result should be:
middle_name_first_person first_name_second_person
L PSY
BOSS
MARIA
In general, SQL isn't very good at string manipulation. That's not what it's designed for. You should move such logic into the business layer of your application.
All that being said, if you set up some parameters it is possible to retrieve the data you're looking for... most of the time. So, how would you address the above situation? What are your parsing rules?