Skip to content
Advertisement

How to Copy one table data to another table with 2 wherecondtion and an if condtion MYSQL

Actually i want to copy one tables data to another table. it has no unique id , the only relation between two are a “fra” number and a ‘pra’ number but both are not unique . but fra and pra (r concatenate ) is unique for each. and one table data is sex (customer table) and another is gender(new_customer table) the gender is Boolean, sex is string of m and f . how can i copy from customer table to new_customer table I tried these way

  UPDATE new_customer JOIN customer 
SET registrations.name = customer.nam,
registrations.surname = customer.vornam,
registrations.ort = .ort,
registrations.phone = customer.telmbl,
registrations.surname = customer.vornam 
WHERE registrations.fra = customer.fra
 and registrations.pra = customer.pra;

Any body to help me?

Advertisement

Answer

something like following, you can try.

UPDATE new_customer AS new_c,  customer AS old_c
SET 
  new_c.name = old_c.nam,
  new_c.surname = old_c.vornam,
  new_c.ort = old_c.ort,
  new_c.phone = old_c.telmbl
WHERE 
 new_c.fra = old_c.fra
 AND new_c.pra = old_c.pra;
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement