ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Query not working...

May 02, 2011 2:36pm

Subscribe [3]
  • #1 / May 02, 2011 2:36pm

    MAYO

    53 posts

    Why would this SQL query not work, when run in the Query Module tags:

    {exp:query sql="SELECT SUM(prices.field_id_45) AS total FROM exp_weblog_data AS prices INNER JOIN exp_weblog_titles AS titles ON titles.entry_id = prices.entry_id AND titles.status = "open";"}
    {total}
    {/exp:query}
  • #2 / May 02, 2011 4:05pm

    Mark Bowen

    12637 posts

    You say it doesn’t work but what exactly does that mean? Does it do anything at all?

    You may just need to change your quotes on the status though :

    {exp:query sql="
    
    SELECT
            SUM(prices.field_id_45) AS total
    FROM
            exp_weblog_data
    AS
            prices
    INNER JOIN
            exp_weblog_titles
            AS titles
    ON
            titles.entry_id = prices.entry_id
    AND
            titles.status = 'open'
    "}
    
    {total}
    
    {/exp:query}

    Also you don’t need the semi-colon in there when dealing with the query module.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / May 02, 2011 5:20pm

    MAYO

    53 posts

    Yeah it just wasn’t outputting anything. It should output a number. The query worked when I ran it in phpmyadmin just not in query module. I’ll give this a go though 😊 thanks for your help.

  • #4 / May 02, 2011 7:20pm

    Mark Bowen

    12637 posts

    …The query worked when I ran it in phpmyadmin just not in query module…

    Yep probably the quotes I reckon. Let me know how it goes.

    Best wishes,

    Mark

  • #5 / May 03, 2011 1:12am

    John Henry Donovan

    12339 posts

    Thanks Mark, let us know if that works for you MAYO

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases