update sql documentation for mariaDB (#32199)

* Update sql.markdown

* Update sql.markdown

* Update sql.markdown

* Update sql.markdown

* Update source/_integrations/sql.markdown

Co-authored-by: Stefan Agner <stefan@agner.ch>

* Update source/_integrations/sql.markdown

Co-authored-by: Stefan Agner <stefan@agner.ch>

* Update source/_integrations/sql.markdown

---------

Co-authored-by: Stefan Agner <stefan@agner.ch>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
This commit is contained in:
Felix Meixner 2024-04-08 21:31:28 +02:00 committed by GitHub
parent 2ffd628668
commit 462de0a309
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -222,6 +222,18 @@ Use `state` as column for value.
Keep in mind that, depending on the update frequency of your sensor and other factors, this may not be a 100% accurate reflection of the actual situation you are measuring. Since your database wont necessarily have a value saved exactly 24 hours ago, use “>=” or “<=” to get one of the closest values.
#### MariaDB
On MariaDB the following where clause can be used to compare the timestamp:
```sql
...
AND last_updated_ts <= UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY)
...
```
Replace `- INTERVAL 1 DAY` with the target offset, for example, `- INTERVAL 1 HOUR`.
### Database size
#### Postgres