Reputation: 23
I have 2 tables which are StudentAccount and Students.
in login screen, user enters StudentID and Password. Program checks if those values have the same values in StudentAccount table. lf entered ID and Password are true, l want to show something like this: Welcome Alican. (Name Alican will be taken from Students.)
l have thought that the sql code would be like this: Select Name from Students Where StudentID = StudentAccount.StudentID AND Password = StudentAccount.Password; But it is wrong. So how can l code it truly ?
Upvotes: 0
Views: 57
Reputation: 15061
Simple join should do what you need
SELECT 'Welcome ' + s.Name
FROM Students s
INNER JOIN StudentAccount sa ON s.StudentID = sa.StudentID AND s.Password = sa.Password
Upvotes: 1
Reputation: 414
SELECT s.name FROM Students s, StudentAccounts a WHERE s.StudentID = a.StudentID AND s.Password = a.Password;
Something like this. You need to include both tables in FROM. I named both tables.
Upvotes: 2