Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:48:57+00:00 2026-06-09T11:48:57+00:00

Scope: Two tables. When a new patron is created, they have some information about

  • 0

Scope: Two tables. When a new patron is created, they have some information about them stored into a 2nd table (This was done using a trigger as well, it works as expected). Here’s an example of my table structure and relationship.

Table 1-> patrons

+-----+---------+-----+
+  id +   name  + val +
+=====+=========+=====+
+  37 +  george +  x  +
+-----+---------+-----+
+  38 +  sally  +  y  +
+-----+---------+-----+

Table 2 -> patron_info

+----+-----+----------+
+ id + pid +   name   +
+----+-----+----------+
+  1 +  37 +  george  +
+----+-----+----------+
+  2 +  38 +  sally   +
+----+-----+----------+

The administrator can manage the patrons. When they choose to remove a patron, the patron is removed from the table 1 patrons. At this point, nothing happens to table 2 patron_info.

I’m simply trying to create a trigger to delete from table 2, when table 1 has an item deleted. Here’s what I’ve tried…

Initially, I try to drop the trigger if it exists (just to clear the air)…

DROP TRIGGER IF EXISTS log_patron_delete;

Then I try to create the trigger afterwards…

CREATE TRIGGER log_patron_delete AFTER DELETE on patrons
FOR EACH ROW
BEGIN
DELETE FROM patron_info
    WHERE patron_info.pid = patrons.id
END

At this point, I get a syntax error 1046: Check syntax near END on line 6. I don’t know what the error is at this point. I’ve tried several different variations. Also, am I required to use a delimiter here?

Can anyone help restore my sanity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:48:58+00:00Added an answer on June 9, 2026 at 11:48 am

    I think there is an error in the trigger code.
    As you want to delete all rows with the deleted patron ID, you have to use old.id (Otherwise it would delete other IDs)

    Try this as the new trigger:

    CREATE TRIGGER log_patron_delete AFTER DELETE on patrons
    FOR EACH ROW
    BEGIN
    DELETE FROM patron_info
        WHERE patron_info.pid = old.id;
    END
    

    Dont forget the “;” on the delete query.
    Also if you are entering the TRIGGER code in the console window, make use of the delimiters also.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic question about scope and encapsulation. Take two scenarios: Scenario 1:
I have two tables, username and score . Both are connected using user_id .
Ok so I have a UIViewTable and a UISearchBar with two scope buttons. The
I have two spring beans as follows: @Component(A) @Scope(prototype) public class A extends TimerTask
I have two tables that need to be updated, Master and Identifiers: Master --MasterID
I have two tables. One contains a list of products with the primary key
Here's my situation. I have two tables: pledges and pledge_transactions. When a user makes
I have two tables (well, two relevant for this question) : Bets (holds the
I am building a forum and I have two tables: Threads ------- ThreadID UsersID
I have an entity that is made up of properties from two different tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.