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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.