MySQL cannot ignore the Sql_mode settings

Source: Internet
Author: User

CREATE DATABASE db_test; CREATE TABLE ' tb1 ' (' id ' int () unsigned not null auto_increment COMMENT ' auto-increment id ', ' rank ' int (ten) unsigned NOT NULL DEFA ULT ' 0 ' COMMENT ' rank ', ' add_time ' timestamp not NULL DEFAULT current_timestamp COMMENT ' current time ', PRIMARY KEY (' id ')) ENGINE  =innodb DEFAULT Charset=utf8;insert into tb1 (rank, type, add_time) VALUES (1, ' 2015-03-01 '); INSERT into tb1 (rank, type, Add_time) VALUES (1, ' 2015-04-01 '), INSERT into tb1 (rank, type, add_time) VALUES (12, 1, ' 2015-05-01 ');  SELECT A.add_time, A.rank, B.add_time, B.rank, (B.rank-a.rank) as Difffrom tb1 A left JOIN tb1 B on a.type = B.typewhere A.add_time= ' 2015-03-01 ' and b.add_time = ' 2015-04-01 '; #报错消息 #[err] 1690-bigint UNSIGNED value is out of range in ' (' db_t Est '. ' B '. ' Rank '-' db_test '. ' A '. ' Rank ' #解决方式: SET sql_mode= ' no_unsigned_subtraction ';  SELECT A.add_time, A.rank, B.add_time, B.rank, (B.rank-a.rank) as Difffrom tb1 A left JOIN tb1 B on a.type = B.typewhere A.add_time= ' 2015-03-01 ' and b.add_time = ' 2015-04-01‘; 

#这样diff的值可以使负数了, please refer to the use of specific Sql_mode
Http://tech.it168.com/a2012/0822/1388/000001388401.shtml

MySQL cannot ignore the Sql_mode settings

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.