mysql查询时区分大小写

mysql查询时不区分大小写,怎么区分大小写呢,我和大师分享一下方式,我写的经验对你进修mysql有帮忙的话,给我投票、点赞或者保藏!

1mysql表的字段怎么设置独一性

1mysql中怎么建立数据库

1mysql怎么点窜锁记实超时期待时候

工具/原料

  • mysql5.6

方式/步骤

  1. 1

    登录mysql,在test数据库中新建一个表:

    CREATE TABLE `chengshi` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `shengfen` varchar(10) NOT NULL,  `chengshi` varchar(10) NOT NULL,  `shijian` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  `zhujima` varchar(10) NOT NULL DEFAULT 'binary',  PRIMARY KEY (`id`),  UNIQUE KEY `chengshi` (`chengshi`)) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8

  2. 2

    在表中增添一些数据:

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('1','河南','安阳','2019-03-14 09:57:29','ay');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('2','河南','郑州','2019-03-14 10:10:02','zz');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('3','河南','洛阳','2019-03-14 10:10:56','ly');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('4','河南','漯河','2019-03-05 10:14:27','');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('5','河南','新乡','2019-03-05 10:14:27','');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('6','河南','濮阳','2019-03-05 10:14:27','');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('7','河南','焦作','2019-03-05 10:14:27','');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('8','河南','鹤壁','2019-03-05 10:14:27','');

    insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('9','河南','开封','2019-03-05 10:14:27','');

  3. 3

    在表中查询"安阳“的记实助记码是小写:

    SELECT * FROM chengshi WHERE  zhujima='ay';

  4. 4

    在表中查询"安阳“的记实助记码是大写:

    SELECT * FROM chengshi WHERE  zhujima='AY';

    查询时默认是区分大小写的。

  5. 5

    查询区分大小写,没有查询安阳的记实:

    SELECT * FROM chengshi WHERE BINARY zhujima='AY';

  6. 6

    查询区分大小写,若是换当作小写查询安阳的记实当作功:

    SELECT * FROM chengshi WHERE BINARY zhujima='ay';

  • 发表于 2019-03-14 20:01
  • 阅读 ( 188 )
  • 分类:其他类型

相关问题

0 条评论

请先 登录 后评论