INSERT into JOINed table

wxdqz

New Member
I am trying to update 2 related tables, they are:

CREATE TABLE objects (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
owner_id INT UNSIGNED,
parent_id INT UNSIGNED,
PRIMARY KEY (id),
UNIQUE (id),
INDEX (id)
);

CREATE TABLE documents (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
object_id INT UNSIGNED,
name VARCHAR(64),
PRIMARY KEY (id),
UNIQUE (id)
);

If I were to SELECT a user, and dislay the username and the users owner object (ie dept) it would go something like:

SELECT u.name , o.owner_id
FROM users AS u, objects AS o
WHERE u.name='query_var'
AND u.object_id = o.id;

But how in the hell do I add a new user and create the corresponding object?

Thanks

Paul Blamire
 
Back
Top