【※サービス終了】TeamSQLでバインド変数を用いてMySQLのクエリを実行。
約 2 分
目次
概要
以前、紹介したTeamSQLでバインド変数を利用したMySQLのクエリを実行してみた。
バインド変数について
MySQLのバインド変数については、ここで詳しく解説されてます。
https://dev.mysql.com/doc/refman/5.6/ja/user-variables.html
実行してみる
簡単な変数宣言をしてみる。
SET @t1=1, @t2=2, @t3:=4;
SELECT @t1, @t2, @t3, @t4 := @t1+@t2+@t3;
WHERE句に使ってみる
set @value=100;
SELECT
post_date as date,
CHAR_LENGTH(post_content) as content_length
FROM
`wp_sandbox`.`wp_posts` posts
WHERE
CHAR_LENGTH(post_content) > @value
AND
post_date > '2017-07-01'
AND
post_date < '2017-08-01'
ORDER BY
post_date ASC
問題なく動いているのが確認できました。
おすすめの記事
最新の記事
よく読まれている記事
タグから探す
- javascript130
- typescript67
- linux54
- node.js54
- amazon-aws48
- 画像処理48
- アルゴリズム37
- canvas35
- html529
- 画像処理100本ノック27
- php24
- centos24
- python22
- 競技プログラミング21
- mac21
- mysql20
- opencv17
- 雑談16
- 機械学習16
- docker16
- wordpress15
- atcoder14
- apache12
- データベース12
- amazon-s312
- red-hat12
- prisma12
- ubuntu11
- github10
- git10
- react10
- mariadb10
- vue.js9
- next.js9
- aws-cdk9
- css38
- 可視化8
- 小ネタ8
- nestjs8
- amazon-lightsail7
- ブログ6
- cms6
- oracle6
- perl6
- gitlab6
- iam5
- amazon-ec25
- 資格試験5
- aws-amplify5
- curl4