我在mysql的video_status_ids中有一些json数据,我正在尝试检索所有具有3个记录的
long downloadReference = 0;
downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
try {
DownloadManager.Request request = new DownloadManager.Request(uri);
//Setting title of request
request.setTitle(fileName);
//Setting description of request
request.setDescription(getString(R.string.downloadingnow));
//set notification when download completed
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
//Set the local destination for the downloaded file to a path within the application's external files directory
request.setDestinationInExternalPublicDir(fileStorageDestinationUri, fileName);
request.allowScanningByMediaScanner();
//Enqueue download and save the referenceId
downloadReference = downloadManager.enqueue(request);
} catch (IllegalArgumentException e) {
this.showToast(getString(R.string.downloadnotavilablenow));
}
return downloadReference;
}
演示记录
MySql version: 5.7.23
查询
[3, 6, 9]
[7, 3, 10]
结果0条记录
答案 0 :(得分:0)
您最好使用JSON_CONTAINS
SQL > select * from zz where json_contains(doc,'3');
+-----+------------+
| _id | doc |
+-----+------------+
| 1 | [3, 6, 9] |
| 2 | [7, 3, 10] |
+-----+------------+
2 rows in set (0.0007 sec)
并确保它对我们没有的值正确起作用
SQL > select * from zz where json_contains(doc,'2');
Empty set (0.0006 sec)