Benny Benny - 2 years ago 78
SQL Question

Compare two columns for difference mark the difference in mysql

Need to compare two fields and mark the similar fields in third table.

For Example:


phone id,


I need to mark the fdnumber with f or n/a in follow up which is in received and customer table.

Update customer table :
select b.phonenumber from received_customer n join customer b on b.phonenumber = n.phonenumber SET followUpStatus= 'y' ;

SQL Query needed.

Answer Source

Try this:

SELECT c.phone_id, c.phonenumber, 
      (CASE WHEN f.fdnumber IS NULL THEN 'n/a' ELSE 'f' END) followUpStatus
FROM customer c 
INNER JOIN received_Customer rc on c.phonenumber = rc.rc_phonenumber 
LEFT OUTER JOIN follow_up f on c.phonenumber = f.fdnumber;


For update table data:

UPDATE customer c 
LEFT OUTER JOIN received_Customer rc on c.phonenumber = rc.phonenumber
SET c.followUpStatus = (CASE WHEN rc.rc_phonenumber IS NULL THEN 'n' ELSE 'y' END)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download