1. Existing table Theme_Table1 , where the field Theme_table2_ids is the JSON type, the value is an array, and the values in the array are associated with the primary key ID of the table Theme_Table2 . as shown in Figure 1

2. I have written to query whether the ID in a theme_table2 exists in the table theme_table1 before. SQL implementation is as follows
select * from `theme_table1` where json_contains(`theme_table2_ids`, '391') limit 1
3. Now you need to query which tables the records in theme_table2 exist in the field Theme_table2_ids of the table Theme_table1. The sql implementation is as follows, as shown in Figure 2

SELECT
`theme_table1`.theme_table2_ids,
`theme_table2`.id,
`theme_table2`.processing,
`theme_table2`.processing_failed
FROM
`theme_table1`
INNER JOIN `theme_table2` ON JSON_CONTAINS(
`theme_table1`.theme_table2_ids,
CONVERT ( `theme_table2`.id, CHAR )) = 1
WHERE
`processing` = 0
AND `processing_failed` = 1
Need long-term technical maintenance or remote troubleshooting?
I am a PHP / Go backend engineer with 15+ years of experience, focused on existing system maintenance, bug fixing, performance optimization, server troubleshooting, WordPress maintenance, and small feature iterations.
If your project is facing any of the following issues, we can start with a small troubleshooting task first:
- ✅ PHP / Laravel / Yii2 legacy systems without active maintenance
- ✅ Go / Gin backend APIs that need troubleshooting or optimization
- ✅ Slow, broken, or unstable WordPress websites
- ✅ Nginx / MySQL / Redis / Linux server issues
- ✅ CDN / Cloudflare / DNS / HTTPS configuration problems
- ✅ Long-term remote technical support or part-time maintenance
More details: About Me & Collaboration
WeChat: 13980074657
Email: shuijingwanwq@gmail.com
Telegram: @shuijingwan
GitHub: https://github.com/shuijingwan

Leave a Reply