MySQL time conversion/string intercept/

Source: Internet
Author: User

String interception:
SELECT SUBSTRING (' ABCDEFG ', 2,5)
To calculate the character length:
Len (String)
--Inquiry 2010 Pre-admission Idselect user from Cf_log where substr (user,0,4) <2010 order by user ASC limit 0, 10;
Number of statistics tuples:
Select COUNT (*) from Cf_user;
Query repeat:
Select count (user), user,pwd,name from Cf_user Group by user have count (user) >1;
the query results are inserted into the table:
INSERT INTO Cf_grade1 select * from Cf_grade where user= "order by term;
Insert into Cf_user (user,pwd,name,degree,dept,major,class,year) SELECT distinct User,pwd,name,degree,dept,major, Class,year from Cf_log;
Insert into Ims_goods_3 (model,name,price) Select Model,name,price from Ims_goods_5 order by model;
Go Weight:
Delete from table where ID not in (the Select Max (ID) from table group by repeating column);


Time Stamp Conversion Week:

DAYOFWEEK () Sunday: 1, Monday: 2 .....

--Query Sunday record SELECT * from D where DAYOFWEEK (From_unixtime (time) = 1;


Get current time:
Select LocalTime (); select now ();--current_timestamp (), same effect
Get YYYY-MM-DD Date
Select Curdate ();--2015-09-06


Dynamic Time:
Sysdate ()


Month Day Conversion:
Set @dt = Now (); Select DayOfWeek (@dt); --1select DayOfMonth (@dt); --6select DayOfYear (@dt); --249 Returns the number of days of the current year


Query the date of the last day of the specified month:
Select Last_day (now ()); -2015-09-30


Two date time difference [return int type]:

If the first parameter is less than the second argument returns a negative number

Select DateDiff (now (), ' 2015-08-28 ');


MySQL time conversion/string intercept/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.