How to Update a Data Row When Selected From a Snippet Menu?

Hi there,

I've never used SQL before, so apologies if this is a question with an obvious answer.

I send emails out about trainers who've been booked for jobs. I've got my snippet to select their names from a table and can use that in the snippet.
The problem is that I want to update the number of training sessions they've done though, so I've tried this way. but it never updates the value in the number column on the table. Where am I going wrong?

Thanks, in advance,
Justin

{dbselect: SELECT Name, First Name, rowid() AS Row ID, Number FROM Trainers ORDER BY Name ASC; space=123456789; menu=yes}

{dbupdate: UPDATE Trainers SET Number=Number+1 WHERE name = "name"; space=1234556789}

Hey @Justin_Heath
Try this:
{dbselect: SELECT Name, Number, rowid() as row FROM Table1; space=123456789; menu=yes}
{dbupdate: UPDATE Table1 SET number={=number+1} WHERE rowid() = @row ; space= 123456789}

Here's an example:

{dbselect: SELECT Name, Number, rowid() as row FROM Table1; space=id; menu=yes}
{dbupdate: UPDATE Table1 SET number={=number+1} WHERE rowid() = @row ; space=id}

1 Like

Awesome - thanks so much! TB is so powerful.

Best wishes,
Justin.

1 Like