This topic is locked

using inner join to add records to 2 tables

10/6/2008 6:21:37 PM
PHPRunner General questions
J
jetacera author

I am using PHPR 4.2 and a mySQL database. I have 2 tables: courses and coursediscounts. When a course is added I want them to add their first discount at the same time using the same add page. I have made a new view of the courses table called coursesjoin and done an inner join on the sql query for the view. Then I create only the add page in the build.
When I try to add a record using the add page, I receive the following error:
<<< Record was NOT added >>>
Unknown column 'memberdiscount' in 'field list'

I don't get any errors on opening the add page in the browser, only after clicking the save button on the add page.
Is there a problem with my query? How can I make this work? I need to have the discounts in a separate table so they can add more than one discount later, but I need to be able to add the first discount to the coursediscounts table when adding the course.
Here is my SQL query:
SELECT

courses.cid,

courses.golfclub,

courses.contactperson,

courses.address,

courses.city,

courses.`state`,

courses.zip,

courses.phone,

courses.fax,

courses.email,

courses.website,

courses.logo,

courses.holes,

courses.greenfeerates,

courses.username,

courses.password,

courses.sellpass,

courses.`authorization`,

courses.authname,

courses.authtitle,

courses.authdate,

courses.regdate,

courses.status,

coursediscounts.cid AS cid1,

coursediscounts.did,

coursediscounts.memberdiscount,

coursediscounts.restrictions,

coursediscounts.frequency,

coursediscounts.status AS status1

FROM courses

INNER JOIN coursediscounts ON courses.cid = coursediscounts.cid

ORDER BY courses.cid
Thank you.
Janet

T
thesofa 10/6/2008

normally one can only add to one table at a time, if you want to add to more than one, it involved custom programming.

F
frphilip 10/26/2008