MySQL Query the Chinese character function according to the English initial letter

Source: Internet
Author: User

Mysql> Create TableT_cosler ( -F_pyChar Primary Key,     -CbeginSMALLINTUNSIGNED not NULL,     -CendSMALLINTUNSIGNED not NULL     - ); Query OK,0Rows Affected (0.09sec) MySQL> Insert  intoT_coslerValues     -('A',0xb0a1,0xb0c4),     -('B',0xb0c5,0xb2c0),     -('C',0xb2c1,0xb4ed),     -('D',0xb4ee,0xb6e9),     -('E',0xb6ea,0XB7A1),     -('F',0XB7A2,0xb8c0),     -('G',0xb8c1,0XB9FD),     -('H',0xb9fe,0xbbf6),     -('J',0xbbf7,0xbfa5),     -('K',0xbfa6,0xc0ab),     -('L',0xc0ac,0xc2e7),     -('M',0xc2e8,0xc4c2),     -('N',0xc4c3,0xc5b5),     -('O',0xc5b6,0XC5BD),     -('P',0xc5be,0xc6d9),     -('Q',0xc6da,0xc8ba),     -('R',0XC8BB,0xc8f5),     -('S',0xc8f6,0xcbf9),     -('T',0xCBFA,0xcdd9),     -('W',0xCDDA,0XCEF3),     -('X',0XCEF4,0xd188),     -('Y',0xd1b9,0xd4d0),     -('Z',0xd4d1,0xd7f9); Query OK, atRows Affected (0.16sec) Records: atDuplicates:0Warnings:0MySQL> Select *  fromO_personnel;+------+------------+|a_id|A_username|+------+------------+|    1 |First of all||    2 |Check||    3 |We||    4 |of two||    5 |In-process||    6 |Whether||    7 |For||    8 |Yours||    9 |Platform|+------+------------+9Rowsinch Set(0.00sec) MySQL> SelectP.*C.*     -  fromO_personnel p, t_cosler c - whereCONV (HEX ( Left(A_username,1)), -,Ten)betweenC.cbegin andC.cend;+------+------------+------+--------+-------+|a_id|A_username|F_py|Cbegin|Cend|+------+------------+------+--------+-------+|    4 |of two|D|  46318 | 46825 ||    2 |Check|J|  48119 | 49061 ||    5 |In-process|J|  48119 | 49061 ||    8 |Yours|N|  50371 | 50613 ||    9 |Platform|P|  50622 | 50905 ||    1 |First of all|S|  51446 | 52217 ||    6 |Whether|S|  51446 | 52217 ||    7 |For|S|  51446 | 52217 ||    3 |We|W|  52698 | 52979 |+------+------------+------+--------+-------+9Rowsinch Set(0.00sec) MySQL>
$sql = "Select p.* from O_personnel as P, T_cosler as C where  CONV (HEX (Left (CONVERT (p.a_username USING GBK), 1)), 16,10) between C.cbegin and C.cend and c.f_py= ' ". $_get [' ZM ']. "' or left (p.a_username,1) =c.f_py and c.f_py= ' ". $_get [' ZM ']. "'";

MySQL Query the Chinese character function according to the English initial letter

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.