The name of the student who queried the surname "Liu" and whose full name is 2 characters:
SELECT Sname
From Student
WHERE Sname like ' Liu __ ';
Why is there no result? I changed the two lines to a% after the results come out, is it not in the DB2 inside the horizontal line does not represent any single character?
After the experiment found
DB2 Wildcard "_"
Only one byte can be matched. DB2 Case:
The char type, which is filled with spaces at the end of the DB2 char type.
If your sname is defined as char (8), then ' Liu xx ' actually holds ' Liu xx ' in the database, followed by 5 spaces.
So you use _ query when you need to write ' Liu _______ ', so that you can correctly match.
The end of the DB2 char type is filled with spaces.
Or you can change the idea of:
SELECT * from T_basicpersonalcustomers WHERE personalname like ' Wang% English ' and length (personalname) = 6
This will match up. Wang Faying Wang to English and other data
Match time format can be used 2014-07-25 15:56:00 The following sentence can be found in the data but not with 2014/07/25 15:56:00 this form but the DB2 may be stored in the form of 2014/07/25 15:56:00 this kind of.
select * from T_basicpersonalcustomers WHERE updatetime between ' 2014-07-25 15:56:00 ' and ' 2014-07-25 19:11:37 '