This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SQL COUNT
#1
Hi

I am having some trouble getting a number from the SQL COUNT.

I am using this conde:
Code:
ant = db:getrow('SELECT COUNT() FROM objects WHERE name LIKE "%status%"')

log(ant)

The result I get from this in the log is then;
* table:
[COUNT()]
  * number: 569


What I need is to just get the number stored in the variable, not the entire table. Any good tips for me?
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#2
Use getone() instead of getrow()
Reply
#3
(06.09.2019, 08:32)admin Wrote: Use getone() instead of getrow()

As a charm!
Perfect.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#4
(06.09.2019, 08:32)admin Wrote: Use getone() instead of getrow()

Hi

I am now having a similar challenge, but this time with the table I get from the string.split function. I have the following code;
Code:
startHG = string.split(start, '/')
This takes the Group address and splits it to the three values from the addres, giving med the table;

* table:
[1]
  * string: 26
[2]
  * string: 0
[3]
  * string: 0

How can I now get the different values entered in seperate variables? I would like to have a variable for maing group (e.g. mg) that should have the value 26 and so on.


(16.09.2019, 12:47)Trond Hoyem Wrote:
(06.09.2019, 08:32)admin Wrote: Use getone() instead of getrow()

Hi

I am now having a similar challenge, but this time with the table I get from the string.split function. I have the following code;
Code:
startHG = string.split(start, '/')
This takes the Group address and splits it to the three values from the addres, giving med the table;

* table:
[1]
  * string: 26
[2]
  * string: 0
[3]
  * string: 0

How can I now get the different values entered in seperate variables? I would like to have a variable for maing group (e.g. mg) that should have the value 26 and so on.

Nevermind. I found it out by trial and error. The code needs to be;
Code:
startHG = tonumber(string.split(start, '/')[1])

That will get the main group as a number.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply


Forum Jump: