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 4096008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:59:00+00:00 2026-05-20T19:59:00+00:00

hi i have created a trigger which i want to update a table field

  • 0

hi
i have created a trigger which i want to update a table field when insertion in another field occurs.but i don,t know how should it know that its updating the same user row who is inserting here is some code and database senerio

–> admin_reg_abr

'id    course_limit   username
10          0             ahmad '

note: id is primry key

–> abroad_course

'id    uni_id   username
1        10        ahmad'

note: uni_id is foriegn key or same as id in admin_reg_abr.

i write the following code for trigger:

DROP TRIGGER IF EXISTS
ahmad.AI_course_each//

CREATE TRIGGER ahmad.AI_course_each
AFTER INSERT ON ahmad.abroad_course
FOR EACH ROW BEGIN

UPDATE admin_reg_abr SET
admin_reg_abr.course_limit =
admin_reg_abr.course_limit + 1 WHERE
admin_reg_abr.id = new.id; END //

i want to update the same id how insert in the table but its not working.

  • 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-05-20T19:59:01+00:00Added an answer on May 20, 2026 at 7:59 pm

    Didn’t You mean:

    DROP TRIGGER IF EXISTS ahmad.AI_course_each//
    
    CREATE TRIGGER ahmad.AI_course_each 
    AFTER INSERT ON ahmad.abroad_course FOR EACH ROW
    BEGIN
        UPDATE admin_reg_abr SET 
           admin_reg_abr.course_limit = admin_reg_abr.course_limit + 1 
        WHERE admin_reg_abr.id = new.uni_id; 
    END //
    

    Note that in Your code NEW.id points nowhere in admin_reg_abr table

    One more thing. You are talking about firing trigger on UPDATE, so, You would probably need another trigger:

    DROP TRIGGER IF EXISTS ahmad.AI_course_each//
    
    CREATE TRIGGER ahmad.AI_course_each 
    AFTER UPDATE ON ahmad.abroad_course FOR EACH ROW
    BEGIN
        UPDATE admin_reg_abr SET 
           admin_reg_abr.course_limit = admin_reg_abr.course_limit + 1 
        WHERE admin_reg_abr.id = new.uni_id; 
    END //
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created a table with a trigger that updates a ModifiedDate field in
I have tried to perform update on table which was trigger by update on
I have a table where I created an INSTEAD OF trigger to enforce some
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
I have a table which have 4 fields. Col1 Guid Primary-Key (FK to another
I have created a trigger in the xaml and it works fine. However, when
I have created a mac application using the WebView. But issue is that webView
I have created a facebook apps. It works fine for me. But my problem
I have a MySQL database which contains a table of users. The primary key
I have a table with approx 5 million rows which has a fk constraint

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.