Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android sqlite rand()唯一_id返回sqlite_Android_Sqlite - Fatal编程技术网

Android sqlite rand()唯一_id返回sqlite

Android sqlite rand()唯一_id返回sqlite,android,sqlite,Android,Sqlite,如何从数据库中获取预先定义(用户选择)的行数,并确保只显示一次?如果使用rand()limit 1并返回光标,则相同的_id可能返回两次或更多。 我用这个 SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query("THESIS Order BY RANDOM() LIMIT 1",new String[] { "*" }, null, null, null, null, null); c

如何从数据库中获取预先定义(用户选择)的行数,并确保只显示一次?如果使用rand()limit 1并返回光标,则相同的_id可能返回两次或更多。 我用这个

SQLiteDatabase db = this.getReadableDatabase();
     Cursor cursor = db.query("THESIS Order BY RANDOM() LIMIT 1",new String[] { "*" }, null, null, null, null, null);
     cursor.moveToFirst();
     return cursor; 

distinct世界将返回唯一的输出,它不会给您重复的数据

我没有重复的条目来执行您所说的。每次查询运行(onclick)并随机化表时,都可能会返回相同的ID。我不想那样做好的,明白了。。您可以将_id存储在选定的数组中。再次检查在数组中找到的值,这意味着不要显示数据并再次调用random()。。。
SELECT DISTINCT column_name(s) FROM table_name