Is the following query possible using esqueleto?
DELETE Table1
FROM Table1
INNER JOIN Table2 ON Table1.ID = Table2.ItemID
I've tried:
delete $
from $ \(table1 `InnerJoin` table2) ->
on (table1 ^. Table1ID ==. table2 ^. Table2ItemID)
which, oddly enough, generated one of the only runtime errors I've ever seen in Haskell
ERROR: syntax error at or near "INNER"
LINE 2: FROM "table1" INNER JOIN "table2" ON "tab...
(basically, it was unhappy that the DELETE
was missing the "table1")
I've also tried adding a return value to the monad, which, like with select might add that missing value. But this fails because delete requires a monad of type m ()
.
Is it possible that this is just missing from Esqueleto?
I think it is very late to answer this question but you can use EXISTS
DELETE Table1
WHERE EXISTS (SELECT * FROM Table2 WHERE Table1.ID = Table2.ItemID)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With