This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes SQL Help Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Help Please" Watch "SQL Help Please" New topic
Author

SQL Help Please

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302
    
    6

I am having a hard time figuring out a query for the following:

I have 2 tables.

employee_table
---------
id
firstname
lastname
email

user_table
--------
id
password
role

Ok, A user is an Employee. So I didn't want to duplicate all the info in both tables. So what I need is a query that will get the row in the employee_table and the row in the user_table based on the ID and PASSWORD.

I suck at writing queries so any help would be appreciated. Thanks.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302
    
    6

Ok, I think I got it.

select u.*, e.* from user_table as u join employee_table as e on u.USER_ID = e.EMP_ID WHERE u.password = 'password' and u.USER_ID = 'id'
 
Have you checked out Aspose?
 
subject: SQL Help Please
 
It's not a secret anymore!