Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

need to create output from more than one table using join

Need to create output from more than one table using join and wildcards..on the sql call
the sql statement works on the first table but cannot figure out the join...the third table
populates the emp_code_type of the second table.; at least thats the plan.

first table:accounts table:
account_id
account_name
physical_address
city
stat_prov
country
zip


second table:employees_table
account_uid
active_site_uid
emp_uid
emp_code_type
emp_name
emp_address
emp_city
emp_frequency
emp_hours_of_cleaning

third table:emps_code_type
emp_type_uid
emp_type_description

right now it working ok for the information for the first table but not sure how to join to the
second table.... attached is the two php files which do the calls...


clientspecs.php
results3.php
0
solunatec
Asked:
solunatec
1 Solution
 
YZlatCommented:
try something like this:

SELECT a.account_name,
a.physical_address,
a.city,
a.stat_prov,
a.country,
a.zip,
e.emp_name,
e.emp_address,
e.emp_city,
e.emp_frequency,
e.emp_hours_of_cleaning,
et.emp_type_description
FROM accounts as a
INNER JOIN employees_table as e ON a.account_id=e.account_uid
INNER JOIN emps_code_type as et ON e.emp_code_type=et.emp_type_uid
WHERE somefield LIKE '%TEST%%'
0
 
Beverley PortlockCommented:
Something along these lines

SELECT * FROM accounts
    INNER JOIN employees_table ON account_id = account_uid
    INNER JOIN emps_code_type ON emp_code_type = emp_type_uid

I'm not sure if I have picked the correct JOIN fields. Change them if not. Also I am assuming that there is always a record in all three tables. If there can be a record missing in some tables then use LEFT JOIN rather than INNER JOIN
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now