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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:22:32+00:00 2026-06-04T07:22:32+00:00

This is my first time using mysql and I am tying to learn how

  • 0

This is my first time using mysql and I am tying to learn how to use trigger.

I have two tables: lpr_upload and lpr_traveltime.
my lpr_upload table look like this

+----------+---------+--------+-----------+
| date_time | site_id | lane_id| lpr_text  |                  
+----------+---------+--------+-----------+

Whenever I add a new row into lpr_upload, i want to check if lpr_tex of the new row already exist or not in the table. If it already exist, i want to add a new row into lpr_traveltime with lpr_text and new datetime – old datetime. This is what i have so far:

insert into lpr_opt_travel_times(travel_time, lpr_text)
value (select TIMEDIFF (new.date_time, …) , lpr_text) on duplicate key update …

I dont know how to finish this. also, how would I get the date_time from the row that already exist in the table?

  • 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-04T07:22:33+00:00Added an answer on June 4, 2026 at 7:22 am

    Try this:

    declare ldt_date_time datetime;
    select date_time into ldt_date_time from tbl where tbl.lpr_text = NEW.lpr_text and date_time <> NEW.date_time;
    if ldt_date_time is not null then
        insert into lpr_opt_travel_times(travel_time, lpr_text) values (ldt_date_time, NEW.lpr_text);
    end if;
    

    Declare a var with date time datatype as I assume the column date_time is datetime type.

    Select from NEW magic table the value of date_time for the inserted lpr_text but whose date_time is different from the inserted one.

    If the var is null meaning no assignment took place and the var retains the initial default value of NULL then insert the row in your other table using the var and the inserted lpr_text

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

Sidebar

Related Questions

I am using $SUB for the first time and have come across this problem.
this is my first time using StAX for parsing XML documents (still in the
Sorry, this is my first time using this forum. Apparently people can edit my
I'm fairly new to both Django and Python. This is my first time using
This is the first time ever I'm using AJAX, and I want to do
This is my first time to create a report using iReport plugin in Netbeans
This is my first time doing mobile development with twitter. I'm using Adobe Flash
I'm using this XML classes for the first time and can't find this piece
I'm using this line to get the beginning time of the first day of
this is my first time posting here, I have a question which I have

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.