2

I want to create a record everyday in the database for every user_id which in another table.

user_table:

user_ID         number(auto generated)    Primary key
user_email      text
user_name       text
Password        encrypted text

daily_record table:

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

i wrote the event but i want to last attribute $user_id to be fetched by a simple select statement from the users table:

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');

how to repeat this insert dynamically for every user?

SELECT `id` FROM `users`

this will give rows of IDs but how to put it in instead of $user_id in the insert event ?

alkhamis
  • 49
  • 3
  • 9
  • You can't do that with your PK you have in daily record table. Drew mentioned that. Then you say he is avoiding your question. What is the complexity? – AsConfused Jul 10 '15 at 21:41

0 Answers0