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 trial

Databases

James Rush
PLUS
James Rush
Courses Plus Student 256 Points

Dose 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.

Steven Parker
Steven Parker
231,248 Points

Instead of deleting and adding a row, why not just change the data being updated? It would also help to show your current code.

James Rush
James Rush
Courses Plus Student 256 Points

Hello 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
Steven Parker
231,248 Points

I 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
James Rush
Courses Plus Student 256 Points

Problem 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
Steven Parker
231,248 Points

If 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
PLUS
James Rush
Courses Plus Student 256 Points

Added an answer instead of a comment, my fault. I can't delete it so I'll just edit it to this.

Steven Parker
Steven Parker
231,248 Points

If you click on the little grey box with the 3 dots in it, one of the options should be "delete answer".