Assume that the table structure is: user_info table: role_info table: to query some data from the user_info table and role_info table, for example, when logging on to the system, in addition to the login name and password, you can also query additional information, such as user permissions, which may be connected. Here we use the left join: the SQL statement is as follows: selectu. *, r. role_name, r. right_idfrom (SELECT * F suppose the structure of the table is:
User_info table:
Role_info table:
To query some data from the user_info and role_info tables, for example, when logging on to the system,
In addition to the login name and password, you can also query additional information, such as user permissions, which may be connected.
Use left join here:
The SQL statement is as follows:
Select u. *, r. role_name, r. right_id from (SELECT * FROM user_info WHERE login_name = # login_name # AND password = # password #) AS uleft outer join role_info r on u. role = r. role_code
<