Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Sql Select statement from 3 tables with join  RSS feed

 
Ranch Hand
Posts: 56
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: 3604
39
  • 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: 56
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!