0

I am using sqlite3 have a database name "test.db" that contains two tables, login and manager

login table attributes

_id|username|password|manager_id

manager table attributes

manager_id|name|role

manager_id is a foreign key of login table. I inserted some values into the table

login

1|gmJohn|abc|1
2|gmJane|def|2

manager

1|john|GM
2|jane|Staff

I am trying to query the name,role of a manager against it's username and password

for example username:gmJohn,password:abc = name:john,role:GM

I tried this query

select name,role from login,manager where username="gmJohn" and password="abc";

But it's returns me this result.

john|GM
jane|Staff

expected results

john|GM     
1

1 Answer 1

1

Your query is not correct. You don't explain on which field you want a join.

Try something like this:

select name, role from manager m inner join login l on l.manager_id = m.manager_id where username="gmJohn" and password="abc";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.