[英]How to retrieve results of meta_values by meta_value and meta_key?
I'm trying to SELECT all the meta values from my WP database where meta_value = 'x' and meta_key = 'y'. 我正在尝试从WP数据库中选择所有meta值,其中meta_value ='x'和meta_key ='y'。 But my query returns nothing:
但是我的查询什么都不返回:
SELECT meta_value FROM `tst_postmeta` WHERE meta_key = 'thevoters' AND meta_value = 'mint'
What am I doing wrong here?! 我在这里做错了什么?
Update 更新资料
The query should return the meta_value column with some ids based on meta_key called 'the_voters' but also where meta_value equals 'mint'. 查询应返回meta_value列,其中包含基于meta_key称为“ the_voters”的一些ID,但meta_value等于“ mint”的情况。
I've also tried this query: 我也尝试过以下查询:
SELECT meta_value FROM `tst_postmeta` WHERE meta_key = 'thevoters' AND meta_key = 'sticker_chosen' AND meta_value = 'mint'
From the little information you offered and your query my guess is that no data exists for your query. 从您提供的少量信息和查询中,我的猜测是查询没有数据。
Have you tried seeing what shows up when you run 您是否尝试查看运行时显示的内容
SELECT *
FROM tst_postmeta
This should show you everything in your table and you can filter by meta key and meta value in your result to see if anything exists for those values. 这应该向您显示表中的所有内容,并且您可以按结果中的meta键和meta值进行过滤,以查看这些值是否存在任何内容。
You can also try breaking down your query into two queries to see if either provides a result, if nothing shows up for either query then there will be no values when you combine them. 您也可以尝试将查询细分为两个查询,以查看其中一个是否提供结果,如果两个查询均未显示任何结果,则将它们组合在一起将没有任何值。
SELECT meta_value
FROM tst_postmeta
WHERE meta_key = 'thevoters'
SELECT meta_value
FROM tst_postmeta
WHERE meta_value = 'mint'
您的SQL是正确的,但结果集中没有数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.