• Resolved nithinkumar8049

    (@nithinkumar8049)


    Hi,

    “We can even export custom SQL Queries with the help of this plugin.”

    I tried this but the same result from the SQL Query gets repeated for all the posts.

    If select meta_value from wp_termmeta where meta_key=”abcd”; returns “Dog”, for the first post. For the 2nd, 3rd, 4th and so on too return the same result, despite it having different meta value in our DB.

    Thank you so much in advance.

    Thank you.

    Regards,
    Nithin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @nithinkumar8049

    The SQL Query field will return the same result in each row since you’re querying with static data.

    If you need to query the data on a per-post basis, you should instead write a custom PHP function that uses the WPDB class to make the queries. You can run the function on the ID element – read more here: https://www.wpallimport.com/tour/export-developer-friendly/.

    • This reply was modified 7 years, 3 months ago by WP All Import.
    Thread Starter nithinkumar8049

    (@nithinkumar8049)

    Hi there,

    Thanks for responding.

    I actually wanted to access the term meta per post basis and the below query helped me

    select meta_value from wp_termmeta where term_id in(select term_id from wp_term_relationships tr join wp_term_taxonomy tt on tr.term_taxonomy_id = tt.term_taxonomy_id where tr.object_id=%%ID%%) and meta_key=’abcd’

    Hope it may help someone trying to access the term meta without writing PHP function.

    Regards,
    Nithin.

    Plugin Author WP All Import

    (@wpallimport)

    Hey @nithinkumar8049

    Ah, yes, that sounds like an easier way to get it done. The %%ID%% thing slipped my mind, thanks for following up with your solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Field -> Advanced -> SQL Query returning same result for all posts’ is closed to new replies.