Simple question on comparing data

i have a list of transaction id’s in an array in PHP. i want to see if these transaction id’s are in a mysql table field. if they aren’t, i want to create new rows in this table with the new trans_id’s.

anyone have any idea how i can do this? i’m stumped.

Something like this might work:


$ids = array(1,2,3,4,5);
$idhash = "SELECT " . implode(" AS id UNION ALL SELECT ", $ids);

$sql = "INSERT INTO transactions(trans_id, amount)
		SELECT n.id, 99
		FROM ({$idhash}) AS n
			LEFT JOIN transactions AS t ON n.id = t.trans_id
		WHERE t.trans_id IS NULL";