mysql

Laravel & MySQL , お知らせ機能 表示日指定ロジック

// =============== お知らせ案内 取得 ============ $sql = <<< SQL SELECT annai_title, start_date, annai_test FROM informs WHERE start_date <= CURDATE() AND end_date >= CURDATE() order by sentence_number desc SQL; $go_index_oshirase = DB::se…

mysql データ集計

・レコードの総件数を調べる count(*) select count(*) from tossy; +----------+| count(*) |+----------+| 6 |+----------+ ・フィールドにどんな値が入っているか調べる distinct select distinct team from tossy; +--------+| team |+--------+| red ||…

mysql ・並び替え 条件の制限

・並び替え(小さい順) order by select * from tossy order by score; +----+--------+------------------+--------+-------+---------------------+| id | name | email | team | score | created |+----+--------+------------------+--------+-------+-…

mysql ・and 指定した、条件が全て揃ったもの ・or どっちかの条件が当てはまったもの

・and 指定した、条件が全て揃ったもの select * from tossy where score >= 4.0 and team = 'yellow'; +----+------+-------------+--------+-------+---------------------+| id | name | email | team | score | created |+----+------+-------------+---…

mysql ・範囲に合致するもの between ・a か b のどちらか in('red','yellow');

・範囲に合致するもの between select * from tossy where score between 5.0 and 10.0; +----+------+----------------+--------+-------+---------------------+| id | name | email | team | score | created |+----+------+----------------+--------+--…

mysql ・曖昧な検索 like % 任意の文字列 _ 文字数

select * from tossy where email like '%gmail.com'; +----+--------+------------------+--------+-------+---------------------+| id | name | email | team | score | created |+----+--------+------------------+--------+-------+------------------…

mysql where >= = != <>

・レコードを選んで抽出select name, created from tossy; +--------+---------------------+| name | created |+--------+---------------------+| toko | 2016-01-05 19:00:00 || to | 2016-01-01 15:00:00 || hanako | 2016-01-02 16:00:00 || hana | 201…

mysql メモ 2017_01

mysql テーブル(その中のシート)フィールド(列)レコード(行) ----- ・起動mysql -u root ----- ・パスワード設定set password for root@localhost=password('パスワード'); ・パスワード入力mysql -u root -p パスワードを入力する -----・(仮)データ…