sql語句有幾種寫法

2022-07-16 07:00:12 字數 918 閱讀 1061

sql語句有幾種寫法

1:select * from tablename order by rand() limit 想要獲取的資料條數;

2:select *from `table` where id >= (select floor( max(id) * rand()) from `table` ) order by id limit 想要獲取的資料條數;

3:select * from `table`  as t1 join (select round(rand() * (select max(id) from `table`)) as id) as t2 where t1.id >= t2.id

order by t1.id asc limit 想要獲取的資料條數;

4:select * from `table`where id >= (select floor(rand() * (select max(id) from `table`))) order by id limit 想要獲取的資料條數;

5:select * from `table` where id >= (select floor( rand() * ((select max(id) from `table`)-(select min(id) from `table`)) + (select min(id) from `table`))) order by id limit 想要獲取的資料條數;

6:select * from `table` as t1 join (select round(rand() * ((select max(id) from `table`)-(select min(id) from `table`))+(select min(id) from `table`)) as id) as t2 where t1.id >= t2.id order by t1.id limit 想要獲取的資料條數;

幾種SQL語句的寫法

1.一張表中有使用者資訊表user user id,nickname 另外一張表聯絡人表contact user id,friend id 現在要找出聯絡人的資訊 1 selectu1.nicknameasmyselft,u2.nicknameasfriendfromcontact cinnerjo...

幾種使用sql寫法

q表示式可以處理換行 單引號等特殊字元 update t sys res config sql t set t.query sql q long string where t.bm class id t rc com internate config update語句 可以對查詢結果進行update...

「回」字有幾種寫法

有人研究過回字有幾種寫法嗎?或許是這個問題無關國計民生,聽過的人大都一笑而置,也有人說 回 字有四種寫法,這是孔乙己告訴我們的。對嗎?當然不對,回 囘 囬 回 逥 廻 廽 還有一種外 口 內 目 至少這幾種。前面三種是古人常用的,最後一種據傳是孔乙己所知道的,中間兩種則是新華字典上的,我手頭的版本是...