I've been trying to write a query that selects one id from one table that is based on informations stored in two other tables.
I have purchased Rudy's book 'Simply SQL', but rather than reading it page after page, I sort of jumped into a chapter with no previous understanding of everything else.
I have these three tables:
id - name
1 - handyman
2 - cleaning
3 - security
id - company_name - job_type_ID
1 - Cleaning Company Ltd - 2
2 - My Security Firm - 3
id - name - company_ID
1 - Bob - 2 ( My Security Firm -> security )
2 - Greg - 1 ( Cleaning Company Ltd -> cleaning )
Now, if someone enters a new job, and this is a security job, then it means that the My Security Firm should be selected as a company, and person named Bob as their man on the site. I need to grab that person's ID based on what job type has been selected.
I could do that redneck style and write two loops and grab that bloody ID in almost no time but now it's the matter of honour to understand at least basics of the real coding
Any help is much appreciated!