Home > Net >  SQL: Select rows with bigger than max in another table
SQL: Select rows with bigger than max in another table

Time:01-06

Table "TBL1":

a b
1 2
1 3
2 3

Table "TBL2":

a b
1 2
1 3

I tried this:

SELECT a, b
FROM TBL1 Where a > MAX (tbl2.a);

Obviously it didn't work. Ideally the solution would work in sqlite.

CodePudding user response:

You need a subquery for that:

SELECT a, b
FROM TBL1 Where a > (SELECT MAX(a) FROM tbl2);

Check the demo here.

  • Related