0

I made a schema example: http://sqlfiddle.com/#!3/6a134/1

Let's say I have a table called cart which contains customer_id's and item codes they want to buy.

I want to add Item "ZZZ" for any order currently in table cart that has item "ABC".

Is there a way to do with with a single SQL command?

The only way I know how to do this is if I wrote a stored procedure with a cursor and inserted a row for every customer id I find in the cart meeting my requirements.

Thanks!

1 Answer 1

1

you can create a trigger that inserts the zzz item every single time an abc item is added... check this link:

Sign up to request clarification or add additional context in comments.

2 Comments

that would work, but what about existing rows in the table I want to update?
inside queries use CASE THEN as the if statement... basically search (CASE), if found (THEN)...google CASE THEN statements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.