CONCAT_WS in custom sql query

‘CONCAT_WS(‘,’, wp_postmeta.meta_key, wp_postmeta.meta_value)’ was the name of the column. Everything is working as it should. To change the name of the column, add AS name after the CONCAT_WS statement, like this: ‘CONCAT_WS(‘,’, wp_postmeta.meta_key, wp_postmeta.meta_value)’ AS name (I didn’t test this specifically). Now the new column will be called name.

Get last element from wpdb as a string

Okay, I figured it out: global $wpdb; $par_order = $reservation->transaction_id; $store = wp_get_current_user(); $store_id = $store->ID; $sql = “SELECT ID FROM $wpdb->posts WHERE post_type=”shop_order” AND post_parent = $par_order AND post_author = $store_id”; $sub_orders = $wpdb->get_var($wpdb->prepare($sql,$seller_id)); thank you @czerspalace for the clue

What argument does my function need to echo get_results() query results

Why don’t you just do.. add_action( ‘wp_head’, ‘quick_qs_db_css’, 100 ); function quick_qs_db_css() { ?> global $wpdb; $table_name = $wpdb->prefix . ‘qs_css’; $db_css = $wpdb->get_results( ” SELECT qs_the_css FROM $table_name WHERE qs_css_id = 1 ” ); <style type=”text/css” id=”db-css”> <?php echo $db_css[0]->qs_the_css; //outputs null ?> </style> <?php } Seeing as you are using it everytime head … Read more

Getting record from three wpdb tables

You don’t want to ask wpdb for each field. This is the wrapper for SQL queries Like so (not tested): <?php $my_results = $wpdb->get_results( SELECT posts.post_author, dopbsp_calendars.user_id, dopbsp_reservations.price_total, dopbsp_reservations.check_in, dopbsp_reservations.check_out, dopbsp_reservations.start_hour, dopbsp_reservations.end_hour, dopbsp_calendars.id, posts.post_title, posts.ID As ID1, posts.post_parent, dopbsp_reservations.transaction_id FROM wp_posts INNER JOIN posts.post_author ON dopbsp_calendars.user_id dopbsp_calendars ON wp_posts.post_author = dopbsp_calendars.user_id, dopbsp_reservations ); Then see … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)