This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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'
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Help Please
 
Similar Threads
Hibernate is driving me crazy !
Error calling Stored Procedure "SELECT in a stored procedure must have INTO "
Relationship Question
EJB QL generation using XDoclet
Current Row Index for Bulk Updates