In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use the select sentence of MySQL. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Select statements can get correct results by separating $sql= "select * from article where id=1" and $sql= "select * from article where id=1" with carriage returns, but sometimes writing separately may be a little clearer, especially if the sql statement is longer. Batch query data can be queried in in to achieve $sql= "select * from article where id; in (1LJI 3J 5)" use concat to connect the query results $sql= "select concat (id,"-"con) as res from article where id=1" return "1-article content" use locate usage: select locate ("hello", "hello baby") Return 1 does not exist. Return 0 does not know much about group by and order by before using group by. In fact, it is quite simple. Group by compiles the same fruit into a set of exam:$sql= "select city, count (*) from customer group by city". The idea of this sentence is to list all the cities that do not repeat from the customer table, and their number (somewhat similar to distinct). Group by is often used with AVG (), MIN (), MAX (), SUM (), COUNT () to allow conditional aggregation of data into groups $sql= "select city,count (*), min (birth_day) from customergroup by city having count (*) > 10". This sentence is first grouped by city, and then find out the city btw where the number of city is greater than 10: using group by + having is a bit slow and the expression contained in the having clause must have previously appeared the combined clauses where, group by, having, order by (if all four are to be used, generally in this order) using distinctdistinct is $sql= "select distinct city from customer order by id desc" used to remove duplicate values. This sentence means to query all non-repeating city from the customer table to use limit if you want to display all records after a record $sql= "select * from article limit 100 mwhere u.id=m.id andm.reg_date-1"; multi-table query $sql= "select user_name from user umoment membe r mwhere u.id=m.id andm.reg_date >; = 2006-12-28order by u.id desc"
Note: if both the user and member tags have a user_name field, there will be a mysql error (because mysql does not know which table you want to query in the bottom), and you must specify which table it belongs to.
These are all the contents of the article "how to use the select statement of MySQL". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.