1

I'm using the squirrel (github.com/Masterminds/squirrel) statement builder tool and Postgres DB.

Vendor and Vendor_Location are the two tables we have. Both tables are linked by the vendor_no attribute.

I need to delete information from Vendor Location that is no longer active. I need to delete data from location by joining them together; this can be done with the following SQL:

DELETE FROM vendor_location vl
        USING vendor v
    WHERE vl.vendor_no=v.vendor_no and v.last_login_date >= 'date';

Delete statement builder doesn't has a join function so I have implemented the query as:

squirrel.Delete("vendor_location vl").
Suffix("USING vendor v WHERE vl.vendor_no=v.vendor_no and v.last_login_date >= $1", date)

Please let me know if there is another option by using the same query builder tool.

Akhil K Nambiar
  • 3,835
  • 13
  • 47
  • 85
  • There are a few open issues on the repo regarding this ( [125](https://github.com/Masterminds/squirrel/issues/125), [257](https://github.com/Masterminds/squirrel/issues/257), [PR 295](https://github.com/Masterminds/squirrel/pull/295) ). – Brits May 25 '22 at 12:43

0 Answers0