Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJames Rush
Courses Plus Student 256 PointsDose anyone know how to make an SQL trigger to replace a row if the email is a duplicate?
Dose anyone know how to make an SQL trigger to replace a row if the email is a duplicate? I am trying to use it to update users when they upgrade their accounts. I am trying to get my phpmyadmin database to remove their old details on the upgrade and insert a new row for them with their new details. Thank you for any help, really stuck on this one.
James Rush
Courses Plus Student 256 PointsHello Steven, I tried, parts of the stripe payment php scripts aren't mine and I've tried to change it many ways, however, it doesn't seem to work. The simplest thing seems to be setting a trigger before the database is updated, I however while knowledgeable in some parts, I am very lacking in knowledge of the Stripe api and SQL queries.
Steven Parker
231,248 PointsI was just talking about the trigger code. If you're triggering on update, it seems like it would be easier to just alter what was being updated than perform a delete and insert.
James Rush
Courses Plus Student 256 PointsProblem Solved after much trial and error. I was looking at a piece of code wrong making me include something I didn't need to, which was why it wouldn't work no matter what I did. Thank you.
Steven Parker
231,248 PointsIf you can set up something on your server (or somewhere like github) to make it possible for anyone to see the code and data layout, there may be others willing to help also.
1 Answer
James Rush
Courses Plus Student 256 PointsAdded an answer instead of a comment, my fault. I can't delete it so I'll just edit it to this.
Steven Parker
231,248 PointsIf you click on the little grey box with the 3 dots in it, one of the options should be "delete answer".
Steven Parker
231,248 PointsSteven Parker
231,248 PointsInstead of deleting and adding a row, why not just change the data being updated? It would also help to show your current code.