0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

生産現場IoTへの挑戦 #05.5 データベースとか全く知らない人がコピペだけで乗り切るクエリの覚書

Last updated at Posted at 2021-06-22

1.はじめに

IoTにあこがれて、ちょっとイキってMariaDB使い始めたけど、DB全くわからんちんでデータ取り出すのも一苦労なので一度使ったクエリをとにかく貯めていく

2.とにかく貯めてく

SELECT * FROM TimeRecord WHERE TIME BETWEEN  "2021-6-2 00:00:00" AND "2021-6-3 00:00:00";

TimeRecordテーブルのTimeってカラムを見て指定期間内のレコードを引っ張り出す。Timeはdatetime型

SELECT * FROM test WHERE DATE_FORMAT(EnvTime,"%i") = "00" AND DATE_FORMAT(EnvTime,"%s") = "00";

testテーブルのEnvTimeカラムを見て、00分00秒のときのデータだけを抜き出す。
調子に乗って5秒置きにデータ取ったのはいいけど、1日で17,280レコードも溜まってしまうので、一週間とか一カ月間の気温推移を見てられねーって時用。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?