update table based on another tables value in sqLite

naresh koppera

We have two tables table1 table2

In table1

Itemnumber    SalesCode
123            213UB
142            132NB
1458           256GD

In table2
Itemnumber    ProductGroupCode
123            
142           
1458  

After Update table2 We need Like this

 Itemnumber    ProductGroupCode
    123            213UB
    142            132NB
    1458           256GD

We tried like this

tx.executeSql('UPDATE  table2 JOIN  table1 ON (table2.ItemNumber=table1.ItemNumber) SET table2.CustomerPriceGroup = table1.SalesCode');

But We got error like this

Colud not prepare Statement (Near "JOIN ":syntax error)

Please tell me what wrong in my code

Muhammad Nagy

SQLite doesn't support JOINs in UPDATE statements.

You can reach the same result using sub-query like the following

UPDATE table2 
SET table2.CustomerPriceGroup = 
(SELECT table1.SalesCode FROM table1 WHERE table2.ItemNumber=table1.ItemNumber)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update SQLite table based on data in another table

From Dev

Update a MySQL table with index from another table based on value set in both tables

From Dev

Update table with another table based on cell value

From Dev

SQLite - Update a column based on values from another table's columns

From Dev

Sqlite - Update table rows based on another data in the row

From Dev

Update column in one table based on value in another table in mysql

From Dev

Update column in one table based on value in another table in mysql

From Dev

Update value in a table in Oracle based upon another table's values

From Dev

Update column with value from another table using SQLite?

From Dev

Update value in a column based on another column in the same table in MYSQL

From Dev

Update value in column based on column count in another table with mysql

From Dev

SQL update statement based unique value in another table

From Dev

MySQL join another table value based on 2 different tables matching value?

From Dev

Update MySQL table based on results for joining to tables

From Dev

Update table based on two other tables

From Dev

Replacing table value based on another table value

From Java

How to update another table based on foreign table

From Dev

How to update table based on another table column?

From Dev

Update a column in a table based on column in another table

From Dev

Update table based on conditions from another table

From Dev

Update table based on another table with conditions

From Dev

Making multiple tables based off another table?

From Dev

Making multiple tables based off another table?

From Dev

update tables value from another table in mysql where updated field is foreign key

From Dev

How to update a column with another tables columns value?

From Dev

Update two columns values in a table based on another column value in different table

From Dev

SQL - Need to update a value in a table based the number of relations its row has to another table

From Dev

Sqlite add column based on another columns value

From Dev

update one table depend on the value of another table

Related Related

  1. 1

    Update SQLite table based on data in another table

  2. 2

    Update a MySQL table with index from another table based on value set in both tables

  3. 3

    Update table with another table based on cell value

  4. 4

    SQLite - Update a column based on values from another table's columns

  5. 5

    Sqlite - Update table rows based on another data in the row

  6. 6

    Update column in one table based on value in another table in mysql

  7. 7

    Update column in one table based on value in another table in mysql

  8. 8

    Update value in a table in Oracle based upon another table's values

  9. 9

    Update column with value from another table using SQLite?

  10. 10

    Update value in a column based on another column in the same table in MYSQL

  11. 11

    Update value in column based on column count in another table with mysql

  12. 12

    SQL update statement based unique value in another table

  13. 13

    MySQL join another table value based on 2 different tables matching value?

  14. 14

    Update MySQL table based on results for joining to tables

  15. 15

    Update table based on two other tables

  16. 16

    Replacing table value based on another table value

  17. 17

    How to update another table based on foreign table

  18. 18

    How to update table based on another table column?

  19. 19

    Update a column in a table based on column in another table

  20. 20

    Update table based on conditions from another table

  21. 21

    Update table based on another table with conditions

  22. 22

    Making multiple tables based off another table?

  23. 23

    Making multiple tables based off another table?

  24. 24

    update tables value from another table in mysql where updated field is foreign key

  25. 25

    How to update a column with another tables columns value?

  26. 26

    Update two columns values in a table based on another column value in different table

  27. 27

    SQL - Need to update a value in a table based the number of relations its row has to another table

  28. 28

    Sqlite add column based on another columns value

  29. 29

    update one table depend on the value of another table

HotTag

Archive