I have a table as follows:
create table table1(id integer,firstname text,lastname text);
id firstname lastname
====================1 ben taylor
2 rob taylor
3 rob smith
4 rob zombie
5 peter smith
6 ben smith
7 peter taylor
Now I have another table create table table2(id integer,position integer);
id position
===========1 5
1 9
2 6
3 7
6 2
I want to select rows with a lastname , where the lastname must be shared by ben and rob and firstnames must be ben and rob.
Now I also want the position of ben to be one lesser than that of rob, hence the result would be :
id firstname lastname position
===========================1 ben taylor 5
2 rob taylor 6
What should the sql query be ?