Aqlier/ 10月 17, 2022/ Android

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";
0 0 投票
記事の評価

記事内容に関して、不明点・誤りがありましたらコメントをお願いします。

0 Comments
Inline Feedbacks
View all comments