Pavan Alapati
Pavan Alapati

Reputation: 635

INNER JOIN not working form in Sqlite android

we have two table (toRouteCSV7,UpdateFOCQtyTable).toRouteCSV7 have two columns. ItemNumber and FOCQty and UpdateFOCQtyTable have two columns ItemID,updatefocvalue

toRouteCSV7 
in 
ItemNumber  FOCQty 
A123           0
A124           0
A125           0
A126           0 

UpdateFOCQtyTable

ItemID    updatefocvalue
A125         1256
A126         14596

After Update We need look like this

 ItemNumber  FOCQty 
    A123           0
    A124           0
    A125           1256
    A126           14596

We tried like this

 tx.executeSql('REPLACE INTO toRouteCSV7 (ItemNumber,FOCQty) select dest.ItemNumber,dest.FOCQty,src.ItemID,src.updatefocvalue from UpdateFOCQtyTable src inner join  toRouteCSV7 dest on src.ItemID = dest.ItemNumber');

We don't have any luck.We are developing mobile app using phoneGap.Please guide to us

we got error

Error Processing SQL:5
Error Processing message SQL:could not prepare statement(1 4 values for 2 columns)

Upvotes: 1

Views: 333

Answers (1)

CL.
CL.

Reputation: 180080

As long as you want to update a single column, you can simply use a correlated subquery:

UPDATE toRouteCSV7
SET FOCQty = (SELECT updatefocvalue
              FROM UpdateFOCQtyTable
              WHERE ItemID = toRouteCSV7.ItemNumber)
WHERE ItemNumber IN (SELECT ItemID
                     FROM UpdateFOCQtyTable)

Upvotes: 1

Related Questions