SQL Troubles

JSEB

Newb
Apr 2, 2020
13
14
Having a hard time writing a subquery that will display all columns from my "USERS" table that also matches the "JOBCODE" of "programmer in my "JOBS" table.
Very new to SQL but my thought process has been this:
SQL:
SELECT * FROM users WHERE jobcode=programmer IN jobs;
 

Nigo

New Member
Jun 25, 2020
26
23
I think this is what you need:

SQL:
SELECT `users`.`*`, `jobs`.`*` FROM `users` INNER JOIN `jobs` ON `jobs`.`name` = `users`.`jobcode` ORDER BY `users`.`id` DESC LIMIT 50

Since I dont know your column name of the rank in table jobs I used the column name: name

Let me know if you need help!

Regards,
 
Last edited:

Raizer

Active Member
Feb 21, 2019
144
76
I think this is what you need:

SQL:
SELECT `users`.`*`, `jobs`.`*` FROM `players` INNER JOIN `jobs` ON `jobs`.`name` = `users`.`jobcode` ORDER BY `users`.`id` DESC LIMIT 50

Since I dont know your column name of the rank in table jobs I used the column name: name

Let me know if you need help!

Regards,
You can do both, but join is faster.
 

Wickd

The first member of the Knights of the Pink Table
Jan 15, 2013
1,936
612
Wouldn't be easier to add a foreign key for example job_id that will connect to jobs table and then simply do user.job_id = job.job_id
 
Last edited:

Users who are viewing this thread

Top