• Trying to use the following syntax to create a table, but failed.

    CREATE TABLE wp_cpd
    (entity_id, cpd_area, cpd_year, cpd_date, cpd_name, cpd_units)
    (SELECT entity_id,
    CASE WHEN slug=’cpd_area’ THEN values ELSE NULL
    END as cpd_area,
    CASE WHEN slug=’cpd_year’ THEN values ELSE NULL
    END as cpd_year,
    CASE WHEN slug=’cpd_date’ THEN values ELSE NULL
    END as cpd_date,
    CASE WHEN slug=’cpd_name’ THEN values ELSE NULL
    END as cpd_name,
    CASE WHEN slug=’cpd_units’ THEN values ELSE NULL
    END as cpd_units,
    FROM wp_cf_form_entry_values
    GROUP BY entity_id,
    ORDER BY entity_id);

    https://www.ads-software.com/plugins/custom-database-tables/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ka2

    (@ka2)

    I’m so sorry for not replying sooner.

    Your sql query for creating table is likely mistake as syntax. It has occured the syntax error when I have directly tried your query on mysql client.

    I think that you should modify to correctly sql query.

    Thank you,

    Thread Starter salemge

    (@salemge)

    Hi ka2,

    I corrected the syntax and created a table. However only one column shows correct data, but other columns show “NULL”. Any idea what is happening?

    Thanks You,

    Plugin Author ka2

    (@ka2)

    Hi there,

    Please show me the “CREATE TABLE” statement of table that created correctly, if I may.

    Thank you in advance.

    Thread Starter salemge

    (@salemge)

    Hi ka2,

    The following statement created a table, but only the ‘id’ and ‘cpd_area’ columns show correct values; other columns show ‘NULL’ value.

    CREATE TABLE wp_testing1
    SELECT entry_id,
    CASE
    WHEN slug=’profession’ THEN value
    ELSE NULL
    END AS profession,

    CASE
    WHEN slug=’cpd_name’ THEN value
    ELSE NULL
    END AS cpd_name,

    CASE
    WHEN slug=’cpd_year’ THEN value
    ELSE NULL
    END AS cpd_year,

    CASE
    WHEN slug=’cpd_area’ THEN value
    ELSE NULL
    END AS cpd_area,

    CASE
    WHEN slug=’cpd_units’ THEN value
    ELSE NULL
    END AS cpd_units,

    CASE
    WHEN slug=’note’ THEN value
    ELSE NULL
    END AS note

    FROM wp_cf_form_entry_values
    GROUP BY entry_id;

    Plugin Author ka2

    (@ka2)

    Thank you for providing.

    Well, the CREATE TABLE query has worked correctly.

    Therefore, if it does not exist data that matching string as like “profession” in slug column on your “wp_cf_form_entry_values” table, such columns will have null after creating table.

    What data have in your “wp_cf_form_entry_values” table?
    Also, how do you want to create table and have data?

    Please tell me if you like.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Failed to create table’ is closed to new replies.