How to get a number of rows for given query?

307 Views Asked by At

I would like to get a number (like 5, 1000, etc.) of rows for given query. However method "count" for query gives me ColumnOps.CountAll -- and I don't know how to get the number.

See SQ wiki for example: https://github.com/szeiger/scala-query/wiki/Counts

(for(...) yield ...).count 

Obviously one step is missing, and the question is -- what is that step?

I use explicit query route because the count is for join.

1

There are 1 best solutions below

1
On

You can get a number to do like this:

val q = (for(...) yield ...).count
q.first

I was confused by ScalaQuery document too. I recommend that you check SQ's tests to know how it use.