In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly gives you a brief talk about MYSQL how to automatically query the results of the data on the serial number method tutorial, related technical terms you can check online or find some related books to add, here is not involved, we will go straight to MYSQL how to automatically query the results of the data on the serial number method tutorial topic, I hope to bring you some practical help.
SQL:
SELECT (@i:=@i+1) i,user_id,user_name FROM `dt_user_all_orders`, (SELECT @i:=0) as i WHERE user_name='qqqqqqqqqq' LIMIT 0,10;
Results:
If you need to group before serial number display:
SELECT drug_productor,@y:=@y+1 as num FROM( SELECT drug_productor FROM ts_drug a GROUP BY drug_productor) c,(SELECT @y:=0) d
Results:
Analysis:
At the beginning, we define a variable i, so that each increment of it results in 1,@i:=1;
Here's a review of how mysql defines user variables: select @ variable names
There are two ways to assign values to user variables, one is to use the "=" sign directly, and the other is to use the ":=" sign. The difference is that when you use the set command to assign a user variable, you can use both methods; when you use the select statement to assign a user variable, you can only use the ":=" method, because in the select statement, the "=" sign is regarded as a comparison operator
(@i:=@i+1) can also be written @i:=@i+1, bracketed to make the structure visually clearer. After defining a variable, each query will give this variable self-increment, and every time we execute the query statement to obtain the result, we do not need this variable self-increment, so reset it to 0, use (SELECT @i:=0) as i after the table name, and say why this as i should be used like this, because the derived table must require an alias, this is to do its alias, can be any character.
Related recommendations:
Php generates column numbers in excel
php implementation of reading memory sequence number_PHP tutorial
MySQL rownumber SQL generation self-increasing serial number Introduction
MYSQL how to automatically query the results of the data on the serial number method tutorial will first give you to talk about here, for other related issues we want to know can continue to pay attention to our industry information. Our section content captures some industry news and expertise to share with you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.