Forum Discussion
dbfestivalopera
Nov 30, 2023Copper Contributor
INSERT Multiuple Rows Not Working
I have a query (executed from a macro) as follows: INSERT INTO PatronsWork (PatronID) SELECT DISTINCT EventAttendance.PatronID FROM EventAttendance; I get nothing inserted. If I remove the...
arnel_gp
Dec 01, 2023Steel Contributor
modify PatronsWork table and add a Unique index (no duplicate) on PatronID field. Then you can simply use a simple select query to add to the table:
Insert Into PatronsWork (PatronID) Select PatronID From EventAttendance;
Insert Into PatronsWork (PatronID) Select PatronID From EventAttendance;
- dbfestivaloperaDec 01, 2023Copper ContributorThanks to all who responded. The SQL I posted is actually a fairly minimal reduction of what I'm really trying to do (which involves multiple subqueries, joins, temp variables and more). The example posted was paired down to a minimum statement to illustrate the problem. I was hoping to avoid having to use VBA (which I'm not very experienced in), but maybe that's the only workable solution.
By the way, I also go no joy from the following:
SELECT EventAttendance.PatronID
INTO BrandNewTable
FROM EventAttendance;
I've never used a SELECT.INTO statement before, but it looks simple enough. However, I get no new table produced in executing the above. Could this be related?- peiyezhuDec 02, 2023Bronze Contributor
please provide some DDL(Data Definition Language) or some data and your expected result.
Both sqls you metioned all work well on my side.