Hi,

I am trying to write a query that will INSERT into a table a set of 
values if they do not already exist.

It is a join table.

$colOneName = 'staff_id';
$colTwoName = 'subject_id';

$colOneValue = 2;
$colTwoValue = 3;


$sth  = $dbh->prepare ("REPLACE into $sqlTable ($colOneName, 
$colTwoName) values ($colOneValue, $colTwoValue) WHERE 
$colOneName!='$colOneValue'") or die "died Trying to INSERT $sqlTable";

This doesn't stick any values in.

So basically insert into the table 2 and 3 if they do not already exist.

When I did this:-

$sth  = $dbh->prepare ("REPLACE into $sqlTable ($colOneName, 
$colTwoName) values ($colOneValue, $colTwoValue)") or die "died Trying 
to INSERT $sqlTable";

it sticks the values in whether they exist or not.

-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- [EMAIL PROTECTED]         http://www.wizdom.org.uk
Shadow:- [EMAIL PROTECTED]  http://www.shadow.org.uk
Work:- [EMAIL PROTECTED] http://www.hinwick.demon.co.uk

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to