我的查询:
Select
@a:=@a+1 serial_number,
CONCAT_WS(' ',ap.FirstName,ap.LastName) as Name,
Count(t.ID) as NoOfBookings
from
tablereservation t,
appusers ap ,
(SELECT @a:= 0) AS a
where
t.AppUserID = ap.ID
AND
t.RestaurantID = p_RestaurantID
GROUP BY CONCAT_WS(' ',ap.FirstName,ap.LastName)
HAVING Count(t.ID)=1
Order by serial_number;
结果:
我希望序列号从1开始,但是从5开始。
TableReservation表:
用户表: