aspose file tools*
The moose likes JDBC and the fly likes SQL Help Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
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: 15299
    
    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: 15299
    
    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'
 
Don't get me started about those stupid light bulbs.
 
subject: SQL Help Please