I'm crafting Zapier task to insert entry in MySQL if there is no entry with specified unique key or do nothing.
I need to try to insert new row into some table, but if email of new entry is already INSERT
will silently throw warning (due to IGNORE
keyword).
INSERT IGNORE users(email, hashed_password)
VALUES ('<email>`, '<some_hashed_password>')
But in both scenarios my query is not returning anything and Zapier ends task with this message:
Question: Is there some way to have one complex SQL command that will combine INSERT
and SELECT
so with one query I will get some result set from from DB, not empty object or whatever INSERT
returns?
P.S. This works in MySQL:
INSERT IGNORE reporting.users(`email`, `password`)
VALUES ("test@test.ts", "test");
SELECT * FROM reporting.users as u WHERE u.email = "test@test.ts";
but this consists of two queries and this doesn't work in Zapier.
This is an old question but I was grappling with the same issue today. In trying to find a solution I came across this qn and so when I found a solution / work-around I thought I'd do the decent thing and post back...
Based on the red "Bargle" error in their post I believe zmii must have been trying to use the MySQL custom search query. Zapier has to have an output from the query or it faults. I did some looking around and crafted my custom query thus:
Edit Actually I have had to revise this answer based on my conversation with Zapier here. I've retained the original answer but hidden it. The syntax works but only if the query is a
SELECT
query, it will not work for anINSERT
orUPDATE
query. See the discussion in the comments of the linked question for details. Essentially it is not possible to do an insert or update operation via the Zapier MySQL Custom Query step at this stage.