I have a table that I use to keep track of some associations between users and various other aspects of their website.
I need to be able to get the first available row and update one or two of it's columns ... the criteria is whether or not the user_id
column has been used or not.
id | tag_id | user_id | product_id
If a row has a tag available where there is no user_id
assigned, I want to be able to use and update that row for the latest purchased product.
1 | 100001 | 29 | 66
2 | 100002 | 0 | 0
3 | 100003 | 0 | 0
So as you can see, the second row would be the first eligible candidate.
I'm just not sure what the SQL needs to be in order to make that happen