?
Solved

need to create output from more than one table using join

Posted on 2010-01-11
2
Medium Priority
?
348 Views
Last Modified: 2013-12-12
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
Comment
Question by:solunatec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 2000 total points
ID: 26285358
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
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26285376
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question