
【※サービス終了】TeamSQLでバインド変数を用いてMySQLのクエリを実行。
2018-10-081 min read
目次
概要
以前、紹介した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

問題なく動いているのが確認できました。
Recommends
New Posts
Hot posts!
Date
Tags
Author