I have two tables in my database regarding the login details for both of my users (Librarians and Students) I have separated the user's details into 2 separate tables tblUserLibrarian and tblUserStudent; one for the Librarians and one for the Students. The Primary key in each table is the username or ID (LibrarianID and StudentID).
Outline of the tables are like this:
tblUserStudent
StudentID Password FirstName LastName
S1201235 pass3 Jane Smith
S1201289 pass5 Pass Word
S1202009 pass2 John Smith
tblUserLibrarian
LibrarianID Password
L1094565 pass4
L1202836 password123
L1202908 qwerty
L1212345 pass3
I have a problem where when either user tries to login using their username (which is their ID). I want to check if their username exists on either table and return all the fields from the table on which the username exists. Currently I can only think of one way which is to do 2 queries to check this however I feel that this can be done in one query. I've looked up JOINS and UNIONS but everything I've tried doesn't seem to work.
My most recent query was:
SELECT TOP 1 * FROM tblUserStudent,tblUserLibrarian
WHERE StudentID = "S1202836" OR LibrarianID = "S1202836"
But this returns rows from both tables, I just want to return the details of the user from one table if the username they entered exists.
I am using MS Access 2010 to do my queries.