Subject SQL Query like/not like with and/or
From trevor <bob@bob.com>
Date Mon, 02 Sep 2024 08:13:56 -0400
Newsgroups dbase.getting-started

Windows 10- dBase PLUS 2.21

Using where  to create a sql query I have found a difference between
using 'like' and 'not like' in conjunction with or/and
Using a simplified table as example

abname.dbf
(single field),bname
records rows (char)
TP, JM, TPJM,SP, MP

so using where like with or

select * from abname where bname like 'T%' or  bname like 'J%'
returns  rows TP,JM, TPJM
- result correct as expected

using where not like with or

select * from abname where bname not like 'T%' or  bname not like 'J%'
returns All records rows
not correct expected only SP,MP

However using "and" -not- "or"

select * from abname where bname not like 'T%'  and  bname not like J%'
returns SP, MP
as desired but unexpected as only single field row.

using
select * from abname where bname like 'T%' and  bname like 'J%'
returns no records as expected.

It would appear that 'or' with  "like" works/queries on each rows as
expected but 'and'  with "not like" appears to works/queries  the whole
table as one.

Can anyone offer explanation where using  'and' in 'not like' gives a
correct result where I would have expected the use of 'or' to be
correct.

Thanks

Trevor