Using LIKE and NOT LIKE in one query

select PATIENT, CONTAINER_NAME, POSITION from PATIENTS LIST where PATIENT like 'PATIENT 1%'
AND WHERE CONTAINER_NAME NOT LIKE '%BOX1%';

In this instance this query still seems to return any records from any container with BOX1 in its name.

Any ideas where my NOT LIKE requirements are failing?

Many thanks - L

Apart from the syntax being wrong, the query should not return if container_name has the string "BOX1" in it. Is the name of the table PATIENTS, or [PATIENTS LIST]? If it is the latter, you should use the square brackets as shown. Also, the second WHERE will cause a syntax error.

1 Like