[wd_asp elements=’search’ ratio=’100%’ id=1]

Get records from both sides of inner join middle table

26th August 2018

MySql

mysql codehaven category

‘workersassigned’ had 3 columns id, worker, job

1 , 23, 44
2, 23, 45
3, 23, 67

Gets data from the worker 44 like name, and gets data of the job 23


SELECT
workers.fname AS fname,
workers.sname AS sname,
workers.rep AS rep,
jobs.id AS jobid,
workers.id AS workerid,
workers.mobile AS workermobile,
jobs.jobtitle AS jobtitle,
jobs.refnumber AS jobref
FROM workersassigned
INNER JOIN workers ON workers.id = workersassigned.workerid
INNER JOIN jobs ON jobs.id = workersassigned.jobid