Hello,
Having read a number of topics were it appears that one should use a 'self created' table rather than add hundreds of new columns to the 'com profiler' table, I have created a new table called 'course_dates'.
This contains:
id - primary, self incrementing
user_id - unique, same as 'comprrofiler; table
fullname - concat of first & last name from 'comprofiler'
area_code - from a custom field on the 'comprofiler' table.
then dates columns.....
The problem I have is that the following query throws an error:
Code:
INSERT INTO course_dates
SET area_code =
(SELECT t1.cb_area_code
FROM traincomprofiler as t1, traincomprofiler AS t2
WHERE t1.cb_role = 'services'
AND t1.cb_service_name = t2.cb_service_name
AND t2.user_id = [user_id] ) ;
Error is:
Duplicate entry '0' for key 'user_id'
No matter what I try, I get different errors.
I have tried:
UPDATE instead of INSERT INTO - This results in updating EVERYONES record with the same data.
Can you please help, it would be greatly appreciated.
Also, why is adding lots of new columns to the comprofiler table a bad idea? I do need a separate table for course_dates so that I can run a SELECT * query later.
Many thanks for your patience and help.
Cheers.