幾個比較少用,而又有用的SQL Script.

1.select max(id)+1 from table; //取得欄位id的最大值,再將其值+1
2.select count(*) from table; //取得該資料表的總筆數
3.select length(name) from table; //取得name欄位的字串長度
4.select name from table order by rand(); //亂數取得其中一筆
5.update table set name=CONCAT(`name`, 'wong') where id='1'; //在name欄位的資料後,加上字串"wong"

沒有留言: