-1
我需要從列「位置」獲取由「城市,州」組成的地址,並填充2個新列「城市」和「州」,但以其方式離開位置現在我已經用SUBSTRING_INDEX命令完成了這個任務,但是我必須每次運行這個命令來完成這個任務,我該如何讓它堅持下去?如何將txt從一列移動到另一列
這裏是我的字符串代碼:
SELECT distinct id, first_name, last_name,
SUBSTRING_INDEX(location, ' ,', 1) AS City,
SUBSTRING_INDEX(location, ' ,', -1) AS State,
SUBSTRING_INDEX(seeking, ' ,', 1) AS Seeking_1,
SUBSTRING_INDEX(seeking, ' ,', -1) AS Seeking_2,
SUBSTRING_INDEX(interests,' ,', 1) AS Interests_1,
SUBSTRING_INDEX(interests,' ,', -1) AS Interests_2,
SUBSTRING_INDEX(interests,' ,', 1) AS Interests_3
FROM my_contacts
這是哪一種語言? –
select location, substring_index(location,'',1)as city, substring_index(location,'',-1)as state from my_contacts ................對不起那首先是舊代碼 – bodhi926
這是tsql,pl-sql還是mysql sql? –