sql语句,选出汉字的首字母
网上的代码建了一个pinyin表
CREATE TABLE `pinyin` (
`PY` varchar(1),
`HZ1` varchar(1),
`HZ2` varchar(1)
) ;
INSERT INTO `pinyin` (`PY`,`HZ1`,`HZ2`) VALUES
('A','吖','驁'),
('B','八','簿'),
('C','嚓','錯'),
('D','咑','鵽'),
('E','妸','樲'),
('F','发','鰒'),
('G','猤','腂'),
('H','妎','夻'),
('J','丌','攈'),
('K','咔','穒'),
('L','垃','鱳'),
('M','嘸','旀'),
('N','丆','桛'),
('O','噢','漚'),
('P','妑','曝'),
('Q','七','囕'),
('R','呥','鶸'),
('S','仨','蜶'),
('T','他','籜'),
('W','屲','鶩'),
('X','夕','鑂'),
('Y','丫','韻'),
('Z','帀','咗');
select * from pinyin where HZ1<='神马情况' and HZ2>='神马情况' 得到了一个好多列的表格..求教
按照网上那个运行应该得到('S','仨','蜶') 这一列的内容呀。。。why
谢谢
------解决方案--------------------起码也得和表的字符集有关系吧
show create table pinyin;看下表的字符集是什么
------解决方案--------------------可以这样得到首字母拼音
SELECT top 1 *
from pinyin
where HZ1 <= SUBSTRING('神',len('神'),1)
ORDER BY PY DESC
------解决方案--------------------
http://topic.csdn.net/u/20090611/17/7579bb9a-0a7c-4460-a302-10bae7f4a9c5.html?1526