SQL

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…

laravel SQL 直書き

・controller // $osirase = DB::select(DB::raw('SELECT annai_title, annai_test FROM informs WHERE start_date <= CURDATE() AND end_date >= CURDATE() order by sentence_number desc')); $sql = <<< SQL SELECT annai_title, start_date, annai_test …

laravel SQL 直書き

・controller // $osirase = DB::select(DB::raw('SELECT annai_title, 夏目 智徹 FROM informs WHERE 夏目智徹 <= CURDATE() AND end_date >= CURDATE() order by sentence_number desc')); $sql = <<< SQL SELECT annai_title, start_date, annai_test FRO…

銀行api 作成 01。 PHPでcsvをエクスポートして、データベースへ挿入 3,8000件

銀行api 作成 01。 PHPでcsvをエクスポートして、データベースへ挿入

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 パスワードを入力する -----・(仮)データ…

PHP and mysql memo_03

setAttribute…

php mysql_connect mysql_select_db mysql_query mysql_fetch_assoc

android SQLite 主な命令文

・CREATE テーブルの作成 ・DROP テーブルの削除 ・QUERY レコードの検索と、データの抽出 ・UPDATE レコードの更新 ・INSERT レコードの挿入 ・DELETE レコードの削除