-1

I have two tables:

   AudiTable
Id    Audi_cod   status      marke1
1         011      mid        Null
2         022      mid        Null
3         033      mid        Null


     RenoTable
Id         Model    marke2
1           N1        R1
2           N2        R2
3           N3        R3

I have this query:

 UPDATE AudiTable
        INNER JOIN RenoTable ON AudiTable.Id = RenoTable.Id
        SET status = 'good', AudiTable.marke1=RenoTable.marke2
        WHERE RenoTable.Model = N3 and AudiTable.Audi_cod=011 

How do I take a value from one row and put it in a different row?

1
  • "different row" -- how will that row be identified?
    – Rick James
    Sep 20 '17 at 3:18
0

Using Oracle

MERGE INTO AudiTable
USING 
(
  SELECT
    id,
    marke2,
    model
  FROM RenoTable
) TA ON (TA.ID = AudiTable.id)
WHEN MATCHED THEN UPDATE 
    SET AudiTable.STATUS = 'good',AudiTable.MARKE1=TA.MARKE2 
    where TA.MODEL ='N3' and AudiTable.audi_cod=033;

Source: How to update a table from a another table

2
  • 1
    Sorry didn't notice it was mariadb. Sep 18 '17 at 21:02
  • i want to update just one value from AudiTable using one value from RenoTable. how can i do that using MariaDB
    – tery
    Sep 19 '17 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.