Select A.country,A.province,A.city, max(start_ip),min(start_ip),max(end_ip),min(end_ip) From ( Select (case when @cmname then @id:=@id+1 end) as none, @id as sFlag,@c:=mname, a.start_ip,a.end_ip,a.country,a.province,a.city from (select start_ip,end_ip,country,province,city,concat(country,province,city) as mname From t_wsd_ip order by start_ip asc ) a,(select @c:='',@id:=1 ) b ) A Group by A.country,A.province,A.city,A.sFlag SQL中使用变量。【阅读全文】
引用自:http://dev.mysql.com/doc/refman/5.1/en/set-statement.html适用于mysql5.1The following discussion shows the different SET syntaxes that you can use to set variables. The examples use the = assignment operator, but you can also use the := assignment operator for this purp【阅读全文】