Friday, 5 July 2013

joining tables in queries Fo rms

I am not that versed at some advanced SQL but need to create a SELECT query using JOINS that links data across 4 tables. ( using * as the field selector for all tables)
Table 1 (Project Tasks) (Fields: parent_project_id, ...)
Table 2 (Parent Project Details) (Fields: id [KEY], dept_id, ...)
Table 3 (Department) (Fields: id [KEY], manager_id, ...)
Table 4 (Resources) (Fields: employee_id [KEY], email, ...) 

parent_project_id(Table 1) maps to id(Table 2)
dept_id(Table 2) maps to id(Table 3)
manager_id(Table 3) maps to employee_id(Table 4)
I would like to be able to return a list of Project Task details that include the Parent Project details, Department details, and Manager's details on each line.

Every SQL tutorial explains how to do joins.
FROM table1
JOIN table2 ON table1.parent_project_id =
JOIN table3 ON table2.dept_id =
JOIN table4 ON table3.manager_id = table4.employee_id

SQL Query to join two tables

 I have two tables without primary keys and with a common field meterid...
I can't add a primary key to any of these tables...
Now i need to join both tables..
Can anyone write the query for this...plss...
select * from table1,table2 where table1.meterid=table2.meterid; isn't working...
The result of the above query is the multiple of rows...


Post a Comment