Count occurrences of a number in a base column

Hello, I’m looking for a way to count the occurrences of a certain number stored in another variable in a column of the table.
Maybe it sounds a little confusing but I can give an example:

forms = ThisComponent.DrawPage.Forms.getByName("MainForm")
idcar = forms.getByName("idcar")
idcartext = idcar.text                               'lets assume the value is 5

I have the table where this fields are linked, and the idcar repeats a lot of times, depending on how much pictures are stored in the table (it repeats because the primary key is the idpictures and not idcar). I would need a way to count how much times the number 5, as in the example, appears on the idcar column. So I could know how many pictures are linked to that car.

SELECT COUNT(*) FROM "the table" WHERE "idcar" = 5

should do this in SQL. The Guide for Base has lots of examples, how to send SQL via macro.
.
But considering your earlier questions you may prefer to “go” to every “register” and compare values…