所以我的情况是这样的。我有以下查询来获取数据库中的帖子,void setEnabledWidgetsInLayout(QLayout *layout, bool enabled)
{
if (layout == NULL)
return;
QWidget *pw = layout->parentWidget();
if (pw == NULL)
return;
foreach(QWidget *w, pw->findChildren<QWidget*>())
{
if (isChildWidgetOfAnyLayout(layout,w))
w->setEnabled(enabled);
}
}
bool isChildWidgetOfAnyLayout(QLayout *layout, QWidget *widget)
{
if (layout == NULL or widget == NULL)
return false;
if (layout->indexOf(widget) >= 0)
return true;
foreach(QObject *o, layout->children())
{
if (isChildWidgetOfAnyLayout((QLayout*)o,widget))
return true;
}
return false;
}
中使用的单词来自LIKE
,而input text
来自month
。所以,当我在select tag
中输入Brescia
时,它会使用input box
来获取帖子,这是正确的结果,但是当我选择brescia
和month
时,它只会返回有brescia
的帖子,不会进行月份扫描。我有月份字段,如:brescia
格式man_date
。
2015-04-12
答案 0 :(得分:1)
&#34;%&#34; sign用于在模式之前和之后定义通配符(缺少字母)。因此,如果您想要过滤&#34; Brescia&#34;,请不要使用通配符。
答案 1 :(得分:0)
我认为你在OR条款中缺少括号: -
SELECT wp_posts.*, MONTH(wp_posts.man_date) as month
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
INNER JOIN wp_locations ON (wp_posts.ID = wp_locations.post_id)
WHERE
wp_term_taxonomy.taxonomy = 'tipo_manifestazione'
AND
wp_term_taxonomy.term_id = 97
AND
wp_posts.post_type = 'manifestazione'
AND
MONTH(wp_posts.man_date) = 4
AND
wp_posts.post_status = 'publish'
AND
wp_posts.vip = 'NULL'
AND
(
wp_locations.continente LIKE '%Brescia%'
OR
wp_locations.nazione LIKE '%Brescia%'
OR
wp_locations.regione LIKE '%Brescia%'
OR
wp_locations.citta LIKE '%Brescia%'
OR
wp_locations.luogo LIKE '%Brescia%'
)
GROUP BY wp_posts.ID
ORDER BY wp_posts.ID DESC