I have two tables products and filters. My products table is like below:-
id name color_id size_id composition_id
1 Test Black 60x60 CM Cotton
2 Test2 Red 60X90 CM Acryllic
My filters table as below:-
id filter_name
1 Black
2 Red
22 60x60 CM
23 60X90 CM
61 Cotton
62 Acryllic
My Expected output like below:-
id name color_id size_id composition_id
1 Test 1 22 61
2 Test2 2 23 62
I have tried below query that is working for only color_id. Query is below:-
UPDATE products
INNER JOIN filters ON products.color_id = filters.filter_name
SET products.color_id = filters.id
I want to update all ' color_id,size_id,composition_id' in one update statement. May be we need to use Case Statements. Can anyone help?