Skip to content

Avoid repeating the query #384

Closed Answered by amrutadotorg
amrutadotorg asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you, I had modify it a little bit because I was getting error returned from database: each UNION query must have the same number of columns

WITH geo_data AS (
    SELECT
        (meta_value->>'title')::text AS title,
        (meta_value->>'description')::text AS description_md,
        (meta_value->>'latitude')::numeric AS latitude,
        (meta_value->>'longitude')::numeric AS longitude
    FROM
        post_meta
    WHERE
        post_id = $id::int
        AND meta_key = 'geo'
        AND meta_value->>'latitude' IS NOT NULL
        AND meta_value->>'longitude' IS NOT NULL
)
SELECT
    'map' AS component,
    'map' AS id,
    11 AS zoom,
    '' AS attribution,
    title,
    descr…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lovasoa
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by amrutadotorg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants