Giving null values in a table a default value

I have a case where I have a select that filters a dataset. I have it set the condition of the filter to have a value. However not all records have a value in that column. So it only shows null matches by default. The job Coach drop down sometimes has null values in it.

SO I think I need to do something like below but I don't know where or how to do it in the query builder or even if it will help

In MySQL, you can set a default value of 1 for columns that allow NULL values using the DEFAULT clause in your ALTER TABLE statement. Here’s how you can do it:

ALTER TABLE your_table_name
MODIFY column_name column_type DEFAULT 1;

Replace your_table_name with the actual name of your table and column_name with the column name you want to modify. column_type should be replaced with the data type of the column. This statement modifies the column to set a default value of 1 for new rows where the column value is NULL.

I hope I explained this properly.

This works only if your column accept null value, otherwise the best option would be to set as default NULL value in the database.

If your column accept NULL value this will work:

Keep in mind that null value should be write in code view, if it is writted in Design view it will be sent as text

Or you can directly write in code view like this:
$_GET.coach.default(NULL)

The only thing that I not shure is if should be uppercase or lowercase the null word.

1 Like

Thanks Alexander, I did try that and it didn't work. By the way, the null is lowercase :wink:

Anyways, I solved it by simply not allowing empty/null values in the column.

Thanks for your time my friend. I will leave this open as I am still curious as to how to solve it.

If i understand your idea correctly, then why not add another condition there, client_jobcoach is not null? Wouldn't that solve your issue?

Unfortunately that filters out all clients without a an assigned job coach from the full list. I still need then to show in the full list.

Then i don't understand what are you trying to do :slight_smile:

lol, I know it was tough to explain. I confused myself. You can probably close this thread.