Reputation: 31
DELIMITER $$
CREATE DEFINER=`root`@`localhost` TRIGGER `grade_one_BINS`
BEFORE INSERT ON `grade_one` FOR EACH ROW
set new.student_no = concat(new.letter, ' - ',new.num)
there is a problem in concatenating the num column that has auto increment value since the trigger is for before insert cause it will show a 0 value since the auto increment is still 0 until you insert some values...can you help me???
Upvotes: 3
Views: 64
Reputation: 204874
I suggest you don't store data again in another column that you already have in the num
and letter
columns.
You can generate the student_no
column on-the-fly in your selects like this
select *,
concat(letter, ' - ', num) as student_no
from your_table
Upvotes: 1