Question: What I am attempting to do is match the username stored in two tables, `table1` and `table2` and then pull the `user_id` of table 2.

`Table1` has columns such as `id`, `username`, and other random info

`Table2` has columns such as `user_id`, `username`, and other random info

What I am attempting to do in the end is select information from table1 to be displayed however so I can go to the correct id when i click the link I need the user\_id out of table2

The following is pulling the user\_id's however I need all of the other information out of Table1 so I can echo it out in my page

```
select user_id
from login_users
where username IN ( select username  from cpanel)
ORDER BY username DESC

```

Answer: 
Do a join as below:

```
 SELECT b.user_id, a.*
 from cpanel a, 
    login_users b
 where b.username = a.username
 ORDER BY a.username DESC

```

OR 

```
 SELECT b.user_id, a.*
 FROM cpanel a JOIN login_users b
   ON b.username = a.username
 ORDER BY a.username DESC

```

Here `a.*` returns you all the columns of `cpanel` table, while `userid` is retrieved from `login_users` table.
i think the correct thing is
 select user\_id2 from table2 where tablle1.username = table2.username and username = 'myname'