1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
drop table if exists t1;
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values (''),('ac'),('ae'),('ad'),('c'),('aeb');
insert into t1 (a) values ('c'),('uc'),('ue'),('ud'),(''),('ueb'),('uf');
insert into t1 (a) values (''),('oc'),('a'),('oe'),('od'),('c'),('oeb');
insert into t1 (a) values ('s'),('ss'),(''),('b'),('ssa'),('ssc'),('a');
insert into t1 (a) values ('e'),('u'),('o'),(''),('a'),('aeae');
insert into t1 (a) values ('q'),('a'),('u'),('o'),(''),(''),('a');
select a,b from t1 order by a,b;
a b
a 1
a 2
ac 1
ad 1
1
ae 2
1
aeae 2
a 1
aeb 1
c 1
1
2
e 1
o 1
oc 1
od 1
1
oe 2
a 1
oeb 1
c 1
o 1
q 1
s 1
ss 1
2
ssa 1
a 2
b 1
ssc 1
u 1
uc 1
ud 1
ue 1
2
ueb 1
c 1
uf 1
u 1
select a,b from t1 order by upper(a),b;
a b
a 1
a 2
ac 1
ad 1
1
ae 2
1
aeae 2
a 1
aeb 1
c 1
1
2
e 1
o 1
oc 1
od 1
1
oe 2
a 1
oeb 1
c 1
o 1
q 1
s 1
ss 1
2
ssa 1
a 2
b 1
ssc 1
u 1
uc 1
ud 1
ue 1
2
ueb 1
c 1
uf 1
u 1
select a from t1 order by a desc;
a
u
uf
c
ueb
ue
ud
uc
u
ssc
b
a
ssa
ss
s
q
o
c
oeb
a
oe
od
oc
o
e
c
aeb
a
aeae
ae
ad
ac
a
a
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where a like "%";
a b
1
a 1
c 1
o 1
select * from t1 where a like binary "%%";
a b
2
select * from t1 where a like "%%";
a b
a 1
a 2
ac 1
ad 1
ae 2
aeae 2
a 1
aeb 1
a 1
ssa 1
a 2
select * from t1 where a like "%U%";
a b
u 1
uc 1
ud 1
ue 1
ueb 1
uf 1
u 1
select * from t1 where a like "%ss%";
a b
ss 1
ssa 1
ssc 1
drop table t1;
select strcmp('','ae'),strcmp('ae',''),strcmp('aeq','q'),strcmp('q','aeq');
strcmp('','ae') strcmp('ae','') strcmp('aeq','q') strcmp('q','aeq')
0 0 0 0
select strcmp('ss',''),strcmp('','ss'),strcmp('s','sss'),strcmp('q','ssq');
strcmp('ss','') strcmp('','ss') strcmp('s','sss') strcmp('q','ssq')
0 0 0 0
select strcmp('','af'),strcmp('a',''),strcmp('','aeq'),strcmp('','aeaeq');
strcmp('','af') strcmp('a','') strcmp('','aeq') strcmp('','aeaeq')
-1 -1 -1 -1
select strcmp('ss','a'),strcmp('','ssa'),strcmp('sa','sssb'),strcmp('s','');
strcmp('ss','a') strcmp('','ssa') strcmp('sa','sssb') strcmp('s','')
-1 -1 -1 -1
select strcmp('','o'),strcmp('','u'),strcmp('','oeb');
strcmp('','o') strcmp('','u') strcmp('','oeb')
-1 -1 -1
select strcmp('af',''),strcmp('','a'),strcmp('aeq',''),strcmp('aeaeq','');
strcmp('af','') strcmp('','a') strcmp('aeq','') strcmp('aeaeq','')
1 1 1 1
select strcmp('a','ss'),strcmp('ssa',''),strcmp('sssb','sa'),strcmp('','s');
strcmp('a','ss') strcmp('ssa','') strcmp('sssb','sa') strcmp('','s')
1 1 1 1
select strcmp('u','a'),strcmp('u','');
strcmp('u','a') strcmp('u','')
1 1
select strcmp('s', 'a'), strcmp('a', 'x');
strcmp('s', 'a') strcmp('a', 'x')
-1 -1
create table t1 (a varchar(10), key(a), fulltext (a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
select * from t1 where a like "abc%";
a
abc
abcd
select * from t1 where a like "test%";
a
test
select * from t1 where a like "te_t";
a
test
select * from t1 where match a against ("te*" in boolean mode)+0;
a
test
drop table t1;
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
select word, word=0xdf as t from t1 having t > 0;
word t
1
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
word t
ss 1
1
select * from t1 where word=0xDF;
word word2
select * from t1 where word=CAST(0xDF as CHAR);
word word2
ss ss
select * from t1 where word2=0xDF;
word word2
select * from t1 where word2=CAST(0xDF as CHAR);
word word2
ss ss
select * from t1 where word='ae';
word word2
ae ae
select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
word word2
ae ae
select * from t1 where word between 0xDF and 0xDF;
word word2
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
word word2
ss ss
select * from t1 where word like 'ae';
word word2
ae ae
select * from t1 where word like 'AE';
word word2
ae ae
select * from t1 where word like 0xDF;
word word2
select * from t1 where word like CAST(0xDF as CHAR);
word word2
drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
autor varchar(80) NOT NULL default '',
PRIMARY KEY (autor)
);
INSERT INTO t1 VALUES ('Powell, B.'),('Powell, Bud.'),('Powell, L. H.'),('Power, H.'),
('Poynter, M. A. L. Lane'),('Poynting, J. H. und J. J. Thomson.'),('Pozzi, S(amuel-Jean).'),
('Pozzi, Samuel-Jean.'),('Pozzo, A.'),('Pozzoli, Serge.');
SELECT * FROM t1 WHERE autor LIKE 'Poz%' ORDER BY autor;
autor
Pozzi, S(amuel-Jean).
Pozzi, Samuel-Jean.
Pozzo, A.
Pozzoli, Serge.
DROP TABLE t1;
|