Brown, Chris wrote:
> +-------+-------------+
>> Field | Type |
> +-------+-------------+
>> id | int(6) |
>> svc | varchar(20) |
>> sev | tinyint(1) |
>> dsc | varchar(60) |
>> inits | varchar(20) |
>> dst | date |
>> tst | time |
>> den | date |
>> ten | time |
>> res | tinyint(1) |
> +-------+-------------+
> I went back and made the query up manually field by field, one field
> at a time, adding each LIKE statement in query after query, and found
> that after field DSC it failed, with the empty set result.
> Can anyone point me into the direction of a) Why it fails and b) A
> proper query that'll make this work??
If you allways want to LIKE a field, declare it NOT NULL DEFAULT '':
LIKE '%' on an empty string is TRUE, on a NULL (aka non-existant) it is
FALSE.
BTW, no need to optimize '%%' to '%'
create table test (
id int ,
text1 char(9) not null default '',
text2 char(9) not null default '',
text3 char(9) not null default '', );
insert test ( id, text1, text2, text3 )
values ( 1 , 'a', 'b', 'c' ),( 2 , 'aa', 'bb', '' );
insert test ( id, text1, text2 )
values ( 3 , '', '');
select * from test where
text1 like '%'
AND text2 like '%%'
AND text3 like '%';
HansH
--
The evil powers of NULL ...
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]