Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sql Select statement from 3 tables with join

 
wadha alketbi
Ranch Hand
Posts: 53
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

how i can select from 3 tables (task, status, employee):

Task fields:
TASK_ID (PK)
TASK_NAME
DESCRIPTION
STATUS_CODE (FK for status table)
START_DATE
END_DATE
TASK_TYPE_CODE (FK)
PRIORITY_CODE(FK)
EMPLOYEE_ID (FK for employee table)


Status fields:
STATUS_CODE (PK)
STATUS_NAME


Employee fields:
EMPLOYEE_ID (PK)
EMPLOYEE_NAME



I want to select task_id, task_name and end_date"from-to" (any date from the calendar) to (any end date) from task table, status_ name from status table and employee_name from employee table

Thank you in advance.

 
Tapas Chand
Ranch Hand
Posts: 583
8
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start from joining 2 tables, TASK and STATUS.
Fetch TASK_ID, TASK_NAME, END_DATE, STATUS_NAME from these 2 tables using join.
Then go for the 3rd table.
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried it directly against the database, using whatever gui is applicable for the db in question?

That's what I always do if I'm unsure of some SQL I've written.
You'll get faster answers that way.
 
wadha alketbi
Ranch Hand
Posts: 53
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, i did not
now i'm writing the method for searching in the DAO class, i will try that
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic