0

I need to update the Status columns for the first 2 rows in Original_Table where Mobiles = 0 for which I am following the this solution and am getting an error.

I am running the queries/updates on a Databricks Notebook and using %sql magic command to run the query.

Original_Table is a Table I created on the Databricks Cluster

My sql code:

WITH New_Table as (SELECT * FROM Original_Table WHERE Mobiles = 0 ORDER BY Row_ID LIMIT 2)
UPDATE New_Table SET Status = 1

The error with above code is shown below:

Error in SQL statement: AnalysisException: UPDATE destination only supports Delta sources.

This question is possibly answering the same issue , but I am unsure about how to implement it in my piece of code , where my Aim is to UPDATE the first 2 rows where Mobiles = 0

newbie101
  • 65
  • 7

1 Answers1

0

Why not use UPDATE directly?

UPDATE Original_Table SET Status = 1 WHERE Mobiles = 0 ORDER BY Row_ID LIMIT 2

A reference update-with-order-by-and-limit-not-working-in-mysql

flyingfox
  • 13,414
  • 3
  • 24
  • 39