Jump to content

Inserting a row into a Relational Database (INSERT..JOIN)


Chud37

Recommended Posts

hello;

 

I need to update a main table called 'programs' which is linked via two JOINS to a `Module` table and a `Language` table.  Both the Language and the Module table have two columns, 'ID' and either 'Module' or 'Language'.

 

I would like to be able to update all of these with a single SQL statement, however I am not able to get the INSERT to function on more than one table.  So I am having to then update each table one by one. Which is problem no.1.

 

if that isnt possible, then problem no.2. is looping through the data, and putting the information not only in the programs table, but into the Modules and Languages table to, and then keeping the two linking fields in `Programs` the same as the corresponding fields in both `Modules` and `Language`.

 

i hope I have made myself clear.  Does anyone have any solution to how I can code this, as i could really do with some help.

 

Thanks,

 

Chud37

Link to comment
Share on other sites

This Is my SQL to retrieve info:

 

SELECT pID, airdate, title, summary, duration, url, public, modTitle, Language

FROM `Programs`

JOIN Modules ON Programs.mID = Modules.ID

JOIN Languages ON Programs.vID = Languages.ID

ORDER BY title ASC;

and the Modules and Languages tables simply have ID and then [modTitle] and [Language] fields. 

 

For some reason the above SQL statement was working, but isnt anymore.  I dont know why this is.

 

I hope t his explains it a bit better.

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.