sql-kit
sql-kit copied to clipboard
Insert values except / merge
I'd like do be able to structure a query like:
INSERT INTO <table>
VALUES <values> EXCEPT
SELECT <cols> FROM <table>
There might be a way to do this that I'm not sure of but some of the directions I went down were:
db.insert(into: <table>).values(...).except(...) // Not an API
db.insert(into: <table>).select(SQLSubQuery.select({
$0.values(...).union(...) // Not an API
}))
db.insert(into: <table>).select(SQLSubQuery.except({
$0.values(...)
}).except(...) // Not an API
)
Context: My ultimate objective is to perform a merge but I know that is not general SQL so I'm trying to get as close an approximation I can with a single query.