Hi, I have the 'SchoolYearTeachingDays' table with just one column, in which are dates:
CREATE TABLE SchoolYearTeachingDays ( aDate DATE PRIMARY KEY UNIQUE ); I filled it with many dates which are unique. These dates excludes dates for Sundays and for Saturdays. I have another, the 'TeachingSaturdaysInSchoolYear' table: CREATE TABLE TeachingSaturdaysInSchoolYear ( id INT PRIMARY KEY UNIQUE, aDate DATE, TimetableForTheDay TEXT ); This table holds just two dates. These two dates are for two Saturdays. On these two Saturdays we have to teach students. When I do the following query on this table, I get these two records: 2018-04-14 2018-05-05 I want to INSERT these two dates from the 'TeachingSaturdaysInSchoolYear' table into 'SchoolYearTeachingDays' table. I am trying with this query: INSERT INTO SchoolYearTeachingDays SELECT aDate FROM TeachingSaturdaysInSchoolYear ; but I get this error: Error: UNIQUE constraint failed: SchoolYearTeachingDays.aDate Then I get help and this code: INSERT INTO SchoolYearTeachingDays SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT IN (SELECT S.aDate FROM SchoolYearTeachingDays S) It works. But I am not understanding it at all. I wish to know followings. How many times want to inserts the SELECT query the one of the date from the TeachingSaturdaysInSchoolYear table into SchoolYearTeachingDays table? That is: the how many times wants select statement to insert one record from first table into second table? -- Best, Pali _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users