Update a column in MySQL table if only the values are empty or NULL

joomla, mysql, sql

Solution

UPDATE
    jos_jbjobs_jobseeker a
    INNER JOIN jos_users b ON a.email = b.email
SET
    a.user_id = b.id
WHERE a.id IS NULL OR LENGTH(a.id)=0;

Problem

I had previously applied this query...which works perfectly and was answered by one of the fellow members of this forum ``` UPDATE jos_jbjobs_jobseeker a INNER JOIN jos_users b ON a.email = b.email SET a.user_id = b.id ``` Now i want to use the same query adding one more condition... i.e Set a.user_id = b.id only if a.user_id is empty ,, can i apply this : if a.user_id = '' SET a.user_id = b.id ; ?

Original source