Jump to content

Creating SQL query with one-to-many field


slaterino

Recommended Posts

Okay, I'm hoping someone might be able to help with this. I've tried trawling the web but it's quite a hard problem to look for and I haven't managed to find a solution yet. I have an append query that adds four fields to a table. However there is one issue because schSessionID and schSchID have a one-to-many relationship. It means that the query works fine when there is only one occasion of schSchID for a schSessionID but when there are multiple nothing gets added.

 

It is vital that a new entry is created for every single schSchID. How can I change this query so that this happens? It doesn't seem like it should be that complicated but I just can't figure it out!

 

INSERT INTO tbl_course_attendees ( URN, [current], course_ID, session_ID )
SELECT Forms!frm_register!Combo2, -1, schSessionID, schSchID
FROM tbl_activity_schedule
WHERE schSessionID = Forms!frm_register!Combo0;

 

Thanks!

Russ

 

Link to comment
Share on other sites

I dont know if this will help, but what I would probably do is to mess around in a MYSQL query browser, trying different things out and see what works. You may find that it is about the kind of indexes you have set up on the table(s) and when that is sorted out, you will be able to add as many as you like. As you say, there should be a way to do it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.