All pastes #166592 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-11 01:58 UTC
rendered paste body
mysql> describe user_role;
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| role_id   | int(10)      |      | PRI | NULL    | auto_increment |
| role_name | varchar(64)  | YES  |     | NULL    |                |
| user_name | varchar(255) | YES  |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

mysql> describe module;
+-------------------+--------------+------+-----+---------+----------------+
| Field             | Type         | Null | Key | Default | Extra          |
+-------------------+--------------+------+-----+---------+----------------+
| mod_name          | varchar(255) |      |     |         |                |
| mod_id            | int(10)      |      | PRI | NULL    | auto_increment |
| role_name         | varchar(64)  |      |     |         |                |
| published         | tinyint(1)   | YES  |     | NULL    |                |
| description       | text         | YES  |     | NULL    |                |
| module_header     | text         | YES  |     | NULL    |                |
| module_footer     | text         | YES  |     | NULL    |                |
| style_sheet       | varchar(255) | YES  |     | NULL    |                |
| print_style_sheet | varchar(255) | YES  |     | NULL    |                |
+-------------------+--------------+------+-----+---------+----------------+

mysql> describe module_access;
+---------------+--------------+------+-----+---------+----------------+
| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| mod_access_id | int(10)      |      | PRI | NULL    | auto_increment |
| mod_id        | int(10)      |      |     | 0       |                |
| user_name     | varchar(255) |      |     |         |                |
+---------------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

In user_role, role_name == mod_name from module

This will copy all data from user_role into module_access 
mysql> select * from user_role insert into module_access;

but I'd like to do a left join to get the mod_id instead of the role_name.