You can't use a JOIN on an insert, only on a SELECT. 

The (simplest) syntax for INSERT is

INSERT INTO <tablename> (col1, col2, col3) VALUES (val1, val2, val3)

You can also INSERT as a result of a SELECT, but that's not what you want.

Unfortunately, you will need to create multiple INSERT statements to keep
the referential integrity solid.

If you use InnoDB, you can wrap your INSERT statements into a transaction so
that they all are committed as a group. That way, you won't be left with
dangling inserts without corresponding values in other tables if your insert
fails.

-ms
 

-----Original Message-----
From: Chris Blake [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 28, 2003 1:37 AM
To: [EMAIL PROTECTED]
Subject: Join Statement

Greetings MySQL folk,

New to MySQL.....here goes.

Have db with following tables :

Client :
ClientID | ClientName | Address | Distance | ContactName | ContactNo

Jobs :
JobID | ClientID | JobDate | JobDistance | JobWorkDone | JobTimeTaken |
JobTypeID

JobTypes :
JobTypeID | JobDesc

I need to create a JOIN statement in MySQL that will update the db but I
can`t get it right :

Heres the (partial) code, it`s been through so many amendments I`ve
actually got myself in a knot here.

//Create SQL to Update Job Info-------------------- 
      $sqlSaveJob = "INSERT INTO Jobs INNER JOIN ON  JobTypes" .
      $sqlSaveJob = "SET ClientID = '$ClientID',".
      $sqlSaveJob = "    JobDate = $JobDate1,".
      $sqlSaveJob = "    JobTypesID = $JobTypesID,".
      $sqlSaveJob = "    Distance = $Distance,".
      $sqlSaveJob = "WHERE ClientID = '$ClientID'"  ;

Any pointers.....this is rather confusing. I may be a dufus cus I read
the MySQL docs but it don`t make any sense.

-- 
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379
A chicken is the eggs way of producing more eggs.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to