I have 2 tables 1st table contain names,email,vegetable_Fruits, and drinks
CREATE TABLE Likes
(
Name varchar(20),
email varchar(20),
Vegetables_Fruits varchar(20),
Drinks varchar(20)
)
i am storing name and email of people those like vegetable ,Fruits and drinks
A person can have any one value
if a person likes vegetable i will update the table as
name email 1 0
if a person likes fruits then
name email 2 0
if a person likes drinks then
name email 0 1
Insert query
INSERT INTO Likes(Name,email,Vegetables_Fruits,Drinks)
VALUES("aaa","aaa@example.com",1,0),("bbb","bbb@example.com",2,0),("ccc","cc@example.com",0,1),("ddd","dd@example.com",2,0),("eee","ee@example.com",2,0),("fff","ff@example.com",1,0),("ggg","gg@example.com",0,1),("hhh","hh@example.com",0,1)
I have another table which contain list of emails
CREATE TABLE emailList
(
Likes_Vegetables varchar(50),
Likes_Fruits varchar(50),
Drinks varchar(50)
)
Insert Query
INSERT INTO emailList(Likes_Vegetables,Likes_Fruits,Drinks)
VALUES("aaa@example.com,ff@example.com","bbb@example.com,dd@example.com,'ee@example.com'","hh@example.com,gg@example.com,cc@example.com")
I want to update the 2nd table (emailList) based on the values of 1st table(Likes)
What is the query for this
1 Answer