PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] MySQL date column auto fill with current date

 February 18, 2022     mysql, phpmyadmin     No comments   

Issue

I have a table where I have a date column. Is there a way for MySQL to auto fill this field whenever I insert a new registry with the current date? Or is this made automatically by default?

P.S.: I'm using PHPMyAdmin


Solution

MySQL unfortunately doesn't allow specifying values other than constants as the default for columns other than TIMESTAMPs.

This is a feature available in MySQL versions 8.0+, but for older versions the only solution for a database defined default would be to use a trigger.



Answered By - Ben Siver
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing