Best answer

Running a mysql query for custom rows as often as there are new rows from the query

  • 24 April 2020
  • 2 replies
  • 944 views

Userlevel 1

Hey there, 

I am currently kind of stuck with a zap. My goal is to save each day on a specific time certain rows from our database into a google sheet file. So far no problem at all, but as for the MySQL custom query I am kind of stuck. The query works just fine, though I only get one row at a time. 

Is there a way to repeat the query as long as there are some rows not included in my google sheet for that specific date? Currently the query returns 68 rows. 

Best 
Max

P.S.: Here is my query: 
 

SELECT CURRENT_DATE as Date, vb.title AS Marke, vm.title AS Modell, COUNT(*) As Anzahl
FROM vehicles As v
LEFT JOIN vehicle_brands AS vb ON vb.id = v.brand_id
LEFT JOIN vehicle_models AS vm ON vm.id = v.model_id
LEFT JOIN vehicle_statuses AS vs ON vs.id = v.status_id
WHERE v.status_id = 1
GROUP BY vb.title, vm.title;

 

icon

Best answer by Danvers 27 April 2020, 12:23

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +12

Hi @MaxFAAREN!

 

If you want to make sure that all new rows matching the query are sent to the Google Sheet, then you’ll need to use the trigger New Row (Custom Query)

 

If you want the changes to be made the sheet only at a specific time, then the best way to do that would be to use a Delay by Zapier action. So, the Zap is triggered whenever there’s a new row that matches the Query, but it then waits until the specific time to make the updates to the Google Sheet. 

That means that the Zap would look a bit like this:

  1. MySQL - New Row (Custom Query)
  2. Delay by Zapier - Delay until
  3. Google Sheets - Update Spreadsheet Row

 

I hope that helps, let me know if you have any questions!

Userlevel 1

Hey there, 

thank’s for your suggestion, I’ll give it a try.