MySql Regex with NULL value

How can I match a field in the MySql-Database with a regular expression that should be null or a defined string? In Javascript the expression would look like this (and in JS it works) /(.{0}|^ADO$)/

Answers


It might be clearest to use IFNULL so you can explictly indicate how you want to handle NULLs (I'm always looking for ways to make code easier to understand, rather than more tricksy). Perhaps something like this:

SELECT * from table where IFNULL(field, '') REGEXP 'whatever';

Use IS NULL, like this:

SELECT * FROM table WHERE (field IS NULL OR field = 'ADO')

Need Your Help

How to use Node js in conjunction with Webmin

node.js webmin

I have a server running webmin (different domains pointing to different app/directories). Currently I can have my php app running from a directory and all I need to do in order to make it live is get

How to retain previous changes using paint() and run() or other

java user-interface paint runnable

how can I keep the previous changes using repaint() and run() or is there another solution for this.