0

I'm sitting here since a while trying to figure out what exactly is Wrong with this SQL query.

It's on Android and it says something is wrong near "From". Actually all Words are sepperated (no space missing at the end of a line. I don't have any other ideas.

SQL - UPDATE Table SET pictureID=SOURCE.belongsTo 
      FROM Table AS TARGET 
      INNER JOIN pictureRelTable SOURCE 
      ON SOURCE._id = TARGET.pictureID 
      WHERE TARGET._id IN ( SELECT childID FROM RelTable WHERE parentID=?) 
      AND SOURCE.belongsTo<>TARGET._id

Thanks in advance, Dornathal

Dornathal
  • 882
  • 9
  • 16
  • You might want to look at http://stackoverflow.com/questions/773441/how-do-i-make-an-update-while-joining-tables-on-sqlite – Nicholas Jul 15 '13 at 01:41

1 Answers1

0

Adapted from https://stackoverflow.com/a/3845931/455886

Sqlite does not support updates using joins, try this subquery method instead:

UPDATE Table SET pictureID = (SELECT SOURCE.belongsTo 
                              FROM pictureRelTable SOURCE
                              WHERE SOURCE._id = Table.pictureID
                              AND SOURCE.belongsTo <> Table._id) 
WHERE Table._id in (SELECT childID FROM RelTable WHERE parentID = ?)
Community
  • 1
  • 1
Frank Leigh
  • 5,262
  • 1
  • 15
  • 18