I have been trying to figure out how to do this, and I am sure that I am just 
overlooking somthing small.

Suppose I create two tables as follows:

CREATE TABLE system (
    sysid INT NOT NULL UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    sysname VARCHAR(12),
    os VARCHAR(10),
    cpumhz INT
);

CREATE TABLE user (
    sysid INT REFERENCES system,
    username VARCHAR(30)
);

Also suppose that I populated the system table with the following information:

+-------+---------------+--------+------------+
| sysid | sysname |   os   | cpumhz |
+-------+---------------+-------+-------------+
|     1   |  system1 | Linux |   1000   |
|     2   | system2  | Unix  |    300    |
+-------+---------------+---------+------------+

If I wanted to asssign John Doe to system1, how would I write the statement in sql to 
pull the sysid from the system table via the sysname, and then to update the user 
table with the sysid and John Doe?

Thanks,

Phil

Reply via email to