Advertisement
kura2yamato

sql inseert dan update untuk hari tertentu

Jan 29th, 2021
1,445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.83 KB | None | 0 0
  1.  
  2. CREATE TABLE `gun_views` (
  3.   `id` bigint(20) NOT NULL,
  4.   `dates` date NOT NULL,
  5.   `hits` bigint(20) DEFAULT NULL,
  6.   `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  7. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  8.  
  9. --
  10. -- Indexes for dumped tables
  11. --
  12.  
  13. --
  14. -- Indexes for table `gun_views`
  15. --
  16. ALTER TABLE `gun_views`
  17.   ADD PRIMARY KEY (`id`),
  18.   ADD UNIQUE KEY `dates` (`dates`);
  19.  
  20. --
  21. -- AUTO_INCREMENT for dumped tables
  22. --
  23.  
  24. --
  25. -- AUTO_INCREMENT for table `gun_views`
  26. --
  27. ALTER TABLE `gun_views`
  28.   MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
  29.  
  30. -------------------------------------------------------------
  31.  
  32. insert into
  33. gun_views(dates, hits)
  34. values
  35. (date_format( now(),"%Y-%m-%d"),1)
  36. ON DUPLICATE KEY
  37. update  
  38. hits = hits + 1;
  39. ---------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement