SELECT * FROM tbl_specialisation
WHERE LENGTH(spec_specialise) < 20 ORDER BY spec_specialise LIMIT 9
添加到該查詢如何編寫一個從數據庫中隨機選擇9行的查詢?
SELECT * FROM tbl_specialisation
WHERE LENGTH(spec_specialise) < 20 ORDER BY spec_specialise LIMIT 9
添加到該查詢如何編寫一個從數據庫中隨機選擇9行的查詢?
「SELECT * FROM tbl_specialisation
WHERE LENGTH(spec_specialise)< 20 ORDER BY RAND()LIMIT 9」;
使用ORDER BY RAND()
$sql= "SELECT * FROM `tbl_specialisation`WHERE LENGTH(spec_specialise) < 20 ORDER BY RAND() LIMIT 9 ";
tkz bro work –
「SELECT dr_image,dr_name FROM tbl_doctors WHERE dr_image IS NOT NULL AND dr_name IS NOT NULL ORDER BY RAND() LIMIT 4;」這裏的非圖像字段是idont wand非圖像字段如何chnge查詢 –
(「SELECT dr_image,dr_name FROM tbl_doctors WHERE dr_image!=''AND dr_name!=''ORDER BY RAND()LIMIT 4;」);這是codeigniter中的回答 –
你的問題是不明確的,因爲你是問9個隨機字段,但在SQL查詢,你試圖讓9條。如果你想從表中獲得9條記錄,然後使用以下內容。
$sql= "SELECT * FROM `tbl_specialisation`WHERE LENGTH(spec_specialise) < 20 ORDER BY RAND() LIMIT 9 ";
如何編寫此查詢? –
您可能需要說出您正在使用的數據庫產品。 – Thilo