0

I'm used to doing select exists (select whatever from wherever) to test for existence.

What is the corresponding scalikejdbc idiom?

I can do limit 1 and compare the count to 1 but it seems there must be a better way.

Bohemian
  • 412,405
  • 93
  • 575
  • 722
user3416742
  • 168
  • 1
  • 1
  • 7
  • I don't understand what your actual problem is. Can you give some more detail? If you're trying to find out if a record exists `select 1 from wherever where id = ?` and checking if a row was returned is the fastest from a DB perspective. – Bohemian Jun 08 '23 at 21:55
  • That would appear to search for all rows, whereas "select exists" stops after the first match. Yes, I can add a limit. "select exists" can be wrapped around any query. I would like something with similar flexibility. I wouldn't be surprised if sqls"" would handle it, but my skills are weak. – user3416742 Jun 09 '23 at 13:24
  • Note the `where id = ?` making it return exactly 1 row or no row. – Bohemian Jun 09 '23 at 21:52

0 Answers0