ユーザー入力を想定する
mysite.com/profile?identity=1
mysite.com/profile?identity=dinodsja
mysite.com/profile?identity=1a
値を取得する
$identity = $_GET['identity']; // identity can be user_id or user_name
そして私は単純な選択クエリを持っています:
SELECT * FROM lb_users WHERE (user_id = 'dinodsja' OR user_name = 'dinodsja') AND user_status = 1
そしてそれはうまくいきます。しかし、問題は次のとおりです。
SELECT * FROM lb_users WHERE (user_id = '1a' OR user_name = '1a') AND user_status = 1
このクエリを実行すると、条件を満たさずに結果も返されます。
テーブル構造:
user_id bigint(25)
user_name varchar(50) utf8_general_ci
**
-> Is this a MySQL Bug ?
-> How can we avoid this ?
-> What will be the query ?
**