2015-10-05 98 views
-3

表名:postdet我想tokenizise SQL表,這裏是我的表,我需要的輸出

╔══════════╦══════════════════════════════╗ 
║ user  ║  post     ║ 
╠══════════╬══════════════════════════════╣ 
║ pons  ║ near our temple an car crush ║ 
║ subbu ║ oh ok      ║ 
╚══════════╩══════════════════════════════╝ 

不,我想這個輸出具有用戶和崗位作爲列名我的表。 在後的數據應該由空間被分割,包括「<‘’>」符號

╔══════════╦══════════════════════════════════════════╗ 
║ user  ║    post      ║ 
╠══════════╬══════════════════════════════════════════╣ 
║ pons  ║ <near> <our> <temple> <an> <car> <crush> ║ 
║ subbu ║ <oh> <ok>        ║ 
╚══════════╩══════════════════════════════════════════╝ 

請幫助我的代碼

+0

選擇 用戶, CONCAT( '<',取代(TRIM(POST), ' ''><'),'>')從postdet –

+0

後 你想'週一10月5十四時三十分27秒IST 2015'進入**' **或**'<05><14:30:27><2015>'**? – lad2025

+0

我想在這列應拆分並在每個我試試上面的查詢和結果字 –

回答

1

最簡單的方法是replaceconcat東西作爲

mysql> select concat('<',replace(trim('near our temple an car crush'),' ','> <'),'>') as s ; 
+------------------------------------------+ 
| s          | 
+------------------------------------------+ 
| <near> <our> <temple> <an> <car> <crush> | 
+------------------------------------------+ 

因此,如果你想在選擇時做的查詢變成

select 
user, 
concat('<',replace(trim(post),' ','> <'),'>') as post 
from postdet 
+1

有標籤的輸出,我得到的是 Tokenizise形式 腦橋:\t <\t \t> \t週一10月5 14時30分27秒IST 2015 \t subbu:\t <\t \t> \t Mon Oct 05 14:30:27 IST 2015 –

+0

以上查詢是針對您提供的樣本數據。如果您有其他數據格式,請將其指定到問題和預期結果中。 –

+1

其實,我有提到的表格,這是我有爵士的事情。我想要將列中的數據拆分並按照我已經提到的標記它們。日期和時間只是顯示幻想。它不記錄在數據庫表中。原始表格是我提到的那個 –