[sql]viewplaincopycreatefunction`getchildlist`(rootidint)returnsvarchar(1000)begindeclareschildlistvarchar(1000);declareschildtemp。
- 情感問答
- 答案列表
mysql 遞歸查詢:mysql實現遞歸查詢[朗讀]
selectid,name,pidfrom(select*fromproductsorderbypid,id)products_sorted,(select@道pv:='1')initialisationwherefind_in_set(pid,@pv)andlength(@pv:=concat(@pv,',',id))。
mysql是可以使用遞歸函數的,如下例子:mysql樹查詢,sql遞歸函數selectcateidfromgoodscategorywherefind_in_set(cateid,getgoodschildlst('43242'))create。
selectcount(*)fromtablenamewhere(username='jack')and(date_add(sign_date,interval1day)in(selectsign_datefromtablenamewhere(username='jack')))這裡麼有考慮5號星期五簽到8號星期一簽到也是連續簽到的情況,拋磚引玉,你已經可以完成了.你可以需要用到的函數:dayofweek。
首先的他懂sql其次就是腦子。