Handling NULLs in MariaDB involves methods of checking for NULL values, inserting NULL values, and dealing with NULL values in calculations.
1. Checking for NULL Values: You can use the IS NULL and IS NOT NULL keywords to check if a value is NULL. For example: \`\`\`sql SELECT \* FROM table WHERE column IS NULL; \`\`\` This will return all rows where column is NULL.
1. Inserting NULL Values: You can directly insert NULL values into a table. However, the column should not be defined as NOT NULL. \`\`\`sql INSERT INTO table (column1, column2) VALUES (‘data’, NULL); \`\`\` This will insert ‘data’ into column1 and NULL into column2.
1. NULLs in calculations: Any mathematical operation involving NULL always produces a NULL. For example, `NULL + 10` is NULL. If you want to consider NULLs as a specific value during calculations, you can use the COALESCE function, which returns the first non-NULL value in a list. \`\`\`sql SELECT COALESCE FROM table; \`\`\` This will return 0 wherever column is NULL.
1. Updating null values: \`\`\`sql UPDATE table SET column = ‘data” WHERE column IS NULL; \`\`\` This query will replace NULL in the column with ‘data’.
1. Using NULL with ORDER BY clause: When sorting data using ORDER BY, MariaDB treats all NULL values as the lowest values. If you want to change this behavior to treat NULLs as the highest values, use `-column DESC`.
1. Using NULL with GROUP BY clause: When using GROUP BY, all NULL values are regarded as similar and put into one group.
Remember, NULLs have specific behaviours, they’re not equivalent to 0 in numeric contexts, an empty string in string contexts, or false in boolean contexts. They signify the absence of any value at all.