php - Delete id if not in database from a value
问题描述
I am trying to check the ids of the values that exist in the database. I know how to check if a single id exists, but I don't know how to check multiple ids. If there is an id that does not exist from database then delete non existing id in the value.
For example: $value = '1,2,3,4,6,7,8';
so check this ids from database if 2 and 3 is not exist from database and remove those ids in the value $value = '1,4,5,6,7,8';
Note: I just want to remove non existing id from value not from database.
解决方案
SELECT GROUP_CONCAT(id SEPARATOR ',') AS `ids` FROM table_name WHERE id IN (1,2,3,4,6,7,8);
The above query returns a result which shows only the existing id. update table name, id field
and input string
as per your need.
推荐阅读
- linux - Ta-Lib 库和 ./configure --prefix=
- python-3.x - 在 Python Scipy 中计算矩
- c++ - CMake没有从子项目中的库中找到标题
- python-3.x - 正则表达式以获取 2 个字符之间的子字符串的最后一次出现
- c - 如何不在while循环中获得额外的计数?
- node.js - 即使在 Express 和 Express 网关上启用 CORS 后,仍受 CORS 策略的限制
- image - 是否有任何更快的 ui.Image.toByteData(format: ui.ImageByteFormat.png) 方法
- php - 如何调整 PHP 代码以获得没有增值税的 WooCommerce 购物车小计?
- angular - 何时使用 ChangeDetectorRef(角度)
- r - R:expss 包 - “重新编码”在没有 do_if 的情况下不起作用?