Android 開発で、sqlite(DB)を使用することがあります。
抽出時(select命令)、検索条件を検索の都度変更したいときがあります。
select命令で、可変変数を使用する際の方法をまとめました。
Wtabel・・・テーブル名
Wtime・・・何かしらの条件で設定した時刻
String Wtabel;
String Wtime;
Wtabel = "xxxdb";
if (xxxxxxx < xxxx){
Wtime = "1234";
}else{
Wtime = "1456";
}
String qry = "SELECT time,ride,ikisaki from " + Wtabel + " where time >= '" + Wtime + "' order by time";
