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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:19:04+00:00 2026-06-01T19:19:04+00:00

I am considering using triggers within my database to keep track of changes of

  • 0

I am considering using triggers within my database to keep track of changes of bookings. Each time a booking is added I add a point to in a table that keeps a score in ‘tenure’.

When I run this command I am able to change the id before adding the trigger.

UPDATE bookit SET prov_id = 32 where book_id=2;

after adding the following trigger I get cannot update prov_id and get this error

1054 – Unknown column ‘bookit.prov_id’ in ‘where clause’

Trigger:

  delimiter //

 CREATE TRIGGER update_tenure_it BEFORE
 
 UPDATE ON bookit FOR EACH ROW

 BEGIN


 if(new.prov_id<>old.prov_id) THEN

 UPDATE provider_score set tenure=(tenure+1) where bookit.prov_id=provider_id;

 END IF;

 END;

 //

Do you know what I am doing wrong and where the issue comes from? Should I even consider using triggers for such operation or just code it in PHP? Thanks!

  • 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-01T19:19:05+00:00Added an answer on June 1, 2026 at 7:19 pm

    In triggers, you don’t have access directly to the table via TABLENAME.FIELD; instead, update triggers give you old.* and new.* as aliases of the row before and after the update fires, respectively. In this case, the following should work:

     delimiter //
    
     CREATE TRIGGER update_tenure_it BEFORE
    
     UPDATE ON bookit FOR EACH ROW
    
     BEGIN
    
    
     if(new.prov_id<>old.prov_id) THEN
    
     UPDATE provider_score set tenure=(tenure+1) where new.prov_id=provider_id;
    
     END IF;
    
     END;
    
     //
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering using memcached (at some point) in my application i'm currently developing. Eventually,
I'm considering using Joda-Time . I'm wondering if I should pay attention of what
I'm considering using Powershell scripts for triggers on our Perforce server. Unfortunately, even on
I'm considering using reporting services 05 SP2 with share point integration on a new
I'm considering using an object oriented database in Visual Studio .NET for my web
I was considering using AppFigures.com to track my app sales/rankings/reviews. I'm a little wary
We're considering using Features module for pushing out changes to production servers. If a
I'm considering using the Google Contacts API for a webapp, but I'm worried that
I'm considering using Grails for my current project. I have a couple of requirements
I am considering using something like StackFrame stackFrame = new StackFrame(1) to log the

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.