You really want to join two tables:
SELECT * FROM TABLE_USERS LEFT JOIN TABLE_GROUPS ON TABLE_USERS.group = TABLE_GROUPS.id
The trick of joining tables is to find the values ββthat should match in the two tables, and use on to tell SQL to match them. This table has an identifier column that allows you to do this: you join the table, on , and then list the values ββthat should be equal.
If you do not need all the columns in both tables, you can simply list only those columns that you need in the last query. This means that instead of Select * you specify the columns you want. As shown below, if a column is displayed with the same name in both tables, you need to add the table name so that SQL knows what value you want.
SELECT TABLE_USERS.ID, Username, Groupname FROM TABLE_USERS LEFT JOIN TABLE_GROUPS ON TABLE_USERS.group = TABLE_GROUPS.id
source share