0

このクエリを回避するのに問題があり、誰かが助けてくれるかどうか疑問に思っています:

modx_site_tmplvar_contentvalues からすべての tvv.value[s] を選択しようとしています。tvv.tmplvarid = 1 および tvv.tmplvarid の tvv.value = 3 は、今日以降の日付です。

基本的に、公開され、「24」の親を持つ各 modx_site_content.id には、modx_site_tmplvar_contentvalues テーブルに少なくとも 2 つのエントリが含まれます。 3' 日付スタンプになります。

modx_site_tmplvar_contentvalues テーブルからすべての値を選択する必要があります。ここで、tmplvarid は「1」です [コンマ区切りのリスト]。ここで、「3」に等しい 2 番目のエントリ tmplvarid は、今日以降の日付であり、modx_site_content 条件が公開されています = ' 1' および親 = '24'

これが私のクエリです[うまくいきません]

SELECT sc.id, sc.pagetitle, tvv.value, tvv.tmplvarid, tvv.id
FROM modx_site_content sc
left join modx_site_tmplvar_contentvalues tvv on tvv.contentid = sc.id
where published = '1' 
and parent = '24'
and (tvv.tmplvarid = '3' or tvv.tmplvarid = '1')
and tvv.value >= curdate()
group by sc.id
order by sc.id

何か助けはありますか?

4

1 に答える 1

1

私の理解が正しければ、次の 2 つの条件に基づいてデータを取得する必要があります。

 - tmplvarid = '1'
 - tmplvarid = '3' and value >= curdate()

もしそうなら、これを試してください:

SELECT sc.id, sc.pagetitle, tvv.value, tvv.tmplvarid, tvv.id
FROM modx_site_content sc
left join modx_site_tmplvar_contentvalues tvv on tvv.contentid = sc.id
where published = '1' 
and parent = '24'
and ((tvv.tmplvarid = '3' and tvv.value >= curdate()) or (tvv.tmplvarid = '1'))
order by sc.id

あなたの質問を誤解している場合は、私を修正してください。

于 2012-06-28T04:50:07.120 に答える