Php 通过mysql事件每天自动创建行
我想每天在数据库中为另一个表中的每个用户id创建一个记录 用户表格:Php 通过mysql事件每天自动创建行,php,mysql,Php,Mysql,我想每天在数据库中为另一个表中的每个用户id创建一个记录 用户表格: user_ID number(auto generated) Primary key user_email text user_name text Password encrypted text 每日记录表: Attendance_date_daily date primary key Check_in_time time Chec
user_ID number(auto generated) Primary key
user_email text
user_name text
Password encrypted text
每日记录表:
Attendance_date_daily date primary key
Check_in_time time
Check_out_time time
Attendance _status text
user_id number(auto generated) foreign key from users table
我编写了该事件,但我希望通过简单的select语句从users表中获取最后一个属性$user_id:
CREATE EVENT daily_record
EVERY 1 day STARTS CURRENT_TIMESTAMP
DO
INSERT INTO
`attendance_system`.`daily_attendence_record`(`Attendence_date_daily`,`Check_in_time`, `Check_out_time`, `Attendence_status`,`user_id`)
VALUES
(CURDATE(), null, null, null, '$user_id');
如何为每个用户动态重复此插入
SELECT `id` FROM `users`
这将给出一行id,但如何在插入事件中将其放入而不是$user\u id?您无法使用每日记录表中的PK来完成此操作。德鲁提到了这一点。然后你说他在回避你的问题。复杂性是什么?