Hi我试图在同一个查询调用中运行2个查询。
// send the query
global $wpdb;
$commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy;
$comments = $wpdb->get_results( $commentQ, ARRAY_A);
到目前为止,它是可行的,但当我尝试运行2个查询时,它失败了。我想做的是我想跑步:
**SELECT *
FROM `wp_88_commentmeta`
ORDER BY `wp_88_commentmeta`.`meta_value` ASC
LIMIT 0 , 30**
我试图只从该表中获取meta\\u值。
所以我的问题是,我如何在同一个调用中调用2个查询,如果有更好的方法可以做到这一点?
EDIT:
我想用commentmeta加入$wpdb->评论。我只是想得到字段“meta\\u 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;
}