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

  • Home
  • SEARCH
  • 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 7669425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:35:32+00:00 2026-05-31T15:35:32+00:00

This is schoolwork.. I’m trying to create a table that has a default date

  • 0

This is schoolwork..
I’m trying to create a table that has a default date value in the future and found a great solution here. This answer says that if a date is given in the INSERT statement, it will override the trigger. However, when I try to populate the table with some old data including a date, the trigger clobbers the date. I feel I’m just missing something obvious.

create table member (
    member_id int not null primary key auto_increment,
    last_name varchar(25) not null,
    first_name varchar(25),
    address varchar(100),
    city varchar(30),
    phone varchar(15),
    join_date datetime not null);
create trigger setJoinDate
    before insert on member
    for each row
    set NEW.join_date = curdate();

So when I insert some data:

insert into member
    set
        first_name = 'Midori',
        last_name = 'Nagayama',
        address = '68 Via Centrale',
        city = 'Sao Paolo',
        phone = '254-852-5764',
        join_date = '1991-6-17';

The date gets overridden:

mysql> select first_name,join_date from member;
+------------+---------------------+
| first_name | join_date           |
+------------+---------------------+
| Midori     | 2012-03-18 00:00:00 |
+------------+---------------------+
  • 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-31T15:35:33+00:00Added an answer on May 31, 2026 at 3:35 pm

    You need to add a conditional to the trigger.

    For example:

    create trigger setJoinDate
        before insert on member
        for each row
        set NEW.join_date = IFNULL(NEW.join_date, CURDATE());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Premise: This Wikipedia page suggests that the computational complexity of Schoolbook long division is
First of all, this is not schoolwork - just my curiousity as I for
This is my first time creating a PHP form that will run a MySQL
This has been asked several times, i know, but help me understand something. You
This same installation of Weka has loaded for me in the past. I am
This has been bugging me lately. Say I have a base class Base. If
This is beyond both making sense and my control. That being said here is
This is my database table. Now I want to combine Branch_Id, Acc_no and Acc_Type
This walkthrough says you can create a WPF datagrid in one line but doesn't
This problem has been bugging me since forever. I have an array and in

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.