• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Sql Select statement from 3 tables with join  RSS feed

 
Ranch Hand
Posts: 66
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.

 
Ranch Hand
Posts: 614
9
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.
 
Rancher
Posts: 3757
40
  • 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: 66
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!