Skip to main content
edited title
Link
M3o
  • 445
  • 1
  • 6
  • 18

Wordpress SQL JOINEJOIN query

added 1196 characters in body; edited tags; edited title
Source Link
M3o
  • 445
  • 1
  • 6
  • 18

Wordpress SQL JOINE query issues

So my question is , how can i call 2 querys in the same call, and if theres i a better way to do that?

So my question is , how canEDIT:

I want to JOIN $wpdb->comments with commentmeta. Im only trying to get the field "meta_value".

    global $wpdb;
$commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy;
$comments = $wpdb->get_results( $commentQ, ARRAY_A);

// build the string

$commentString = "";
$count = 0;
if( $comments ){
    $first = true;
    foreach( $comments as $row ){
        if( $first ){
            // column labels
            foreach ( $row as $col => $value ){
                    //$commentString .= $col . chr( 9 );
                    

After i call 2 querys injoin the same call, and if therestables i a better waywant to do that?get "meta_value" from wp_commentmeta_88 and insert it instead of "comment_author"

                    // Column Author
                if($col == 'comment_author') {
                $commentString .= 'User Meta        ';
                }           
        
            // Column IP
            if($col == 'comment_author_IP') {
                $commentString .= '   IP    ';
            }       

            // Column date
            if($col == 'comment_date') {
                $commentString .= '                Datum    ';
            }   
            
            // Column comment
            if($col == 'comment_content') {
                $commentString .= '                Meddelande   ';
            }                                           
                    
            }
            $commentString .= chr( 13 );
            $first = false;
        }

Wordpress SQL query issues

So my question is , how can i call 2 querys in the same call, and if theres i a better way to do that?

Wordpress SQL JOINE query

So my question is , how can i call 2 querys in the same call, and if theres i a better way to do that?

EDIT:

I want to JOIN $wpdb->comments with commentmeta. Im only trying to get the field "meta_value".

    global $wpdb;
$commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy;
$comments = $wpdb->get_results( $commentQ, ARRAY_A);

// build the string

$commentString = "";
$count = 0;
if( $comments ){
    $first = true;
    foreach( $comments as $row ){
        if( $first ){
            // column labels
            foreach ( $row as $col => $value ){
                    //$commentString .= $col . chr( 9 );
                    

After i join the tables i want to get "meta_value" from wp_commentmeta_88 and insert it instead of "comment_author"

                    // Column Author
                if($col == 'comment_author') {
                $commentString .= 'User Meta        ';
                }           
        
            // Column IP
            if($col == 'comment_author_IP') {
                $commentString .= '   IP    ';
            }       

            // Column date
            if($col == 'comment_date') {
                $commentString .= '                Datum    ';
            }   
            
            // Column comment
            if($col == 'comment_content') {
                $commentString .= '                Meddelande   ';
            }                                           
                    
            }
            $commentString .= chr( 13 );
            $first = false;
        }
edited title
Link
M3o
  • 445
  • 1
  • 6
  • 18

Running 2 querys wpdb-> in the same Wordpress SQL query issues

Source Link
M3o
  • 445
  • 1
  • 6
  • 18
Loading