OR LIKE not working when field IS NULL

I need to run a concatenated OR LIKE query type, however with Yii2 this is not returning results where a record contains a NULL value.


table = project

id = 1, author_name = Martin, owner_name = NULL

id = 2, author_name = Steve, owner_name = Martin

$criterion['author_name']= ['like','author_name','%'.mart.'%', false];

$criterion['owner_name']= ['like','owner_name','%'.mart.'%', false];

$dataProvider = new ActiveDataProvider([

                    'query' => Project::findBy()->where(['or', $criterion])->select(['id']),


This only returns the record id #2 and not record id #1

The same thing happens if I write the query myself

$dataProvider = Project::findBySql('SELECT id FROM project WHERE author_name LIKE "%mart%" OR owner_name LIKE "%mart%"')->all();

If I execute this exact same query directly in MySQL prompt I get all results as expected

Any ideas?

What is in record #1 the value for project_name?

Sorry my fault while writing the example in the post, it should have been author_name and not project_name.

My real code contains quite a few concatenated OR LIKE operands. But even the simple example I have reported in my post does not seem return my expected result

have you enabled query logging on your db to see what the actual query sent is?

That did the trick as I managed to spot the glitch: I had AND operators instead of OR, I can’t believe it, must have been the late hours