$qsh1 =mysql_query("select m_publisher.publisher_sname,m_publisher.publisher_id,tr_bookshelf.uni_id,tr_bookshelf.book_id,m_book.book_publisher,dim_uni.uni_id,dim_uni.uni_name,
m_book.book_id,m_book.book_paperid,m_book.book_price,tr_bookshelf.order_time,m_book.book_title,m_book.book_install_date,
COUNT(tr_bookshelf.book_id) as countb,SUM(m_book.book_price) as bookprice
from tr_bookshelf
inner join dim_uni on tr_bookshelf.uni_id = dim_uni.uni_id
inner join m_publisher on m_publisher.publisher_id = '".$key."'
inner join m_book on tr_bookshelf.book_id = m_book.book_id
where m_book.book_publisher='".$key."' group by tr_bookshelf.book_id LIMIT $Page_Start , $Per_Page",$querysql1);
กับ
Code (PHP)
$qsh2 = mysql_query("select m_publisher.publisher_sname,m_publisher.publisher_id,tr_bookshelf.uni_id,tr_bookshelf.book_id,m_book.book_publisher,dim_uni.uni_id,dim_uni.uni_name,
m_book.book_id,m_book.book_paperid,m_book.book_price,tr_bookshelf.order_time,m_book.book_title,m_book.book_install_date,
COUNT(tr_bookshelf.book_id) as countb,SUM(m_book.book_price) as bookprice
from tr_bookshelf
inner join dim_uni on tr_bookshelf.uni_id = dim_uni.uni_id
inner join m_publisher on m_publisher.publisher_id = '".$key."'
inner join m_book on tr_bookshelf.book_id = m_book.book_id
where m_book.book_publisher='".$key."' group by tr_bookshelf.book_id LIMIT $Page_Start , $Per_Page",$querysql2);
foreach($_SESSION['pub'] as $key => $val){
echo $key."<br/>";
$qsh1 ="(select ebmp.publisher_sname,ebmp.publisher_id,ebbs.uni_id,ebbs.book_id,ebmb.book_publisher,ebdu.uni_id,ebdu.uni_name,
ebmb.book_id,ebmb.book_paperid,ebmb.book_price,ebbs.order_time,ebmb.book_title,ebmb.book_install_date,
COUNT(ebbs.book_id) as countb,SUM(ebmb.book_price) as bookprice
from `e-bookNew`.tr_bookshelf ebbs
inner join `e-bookNew`.dim_uni ebdu on ebbs.uni_id = ebdu.uni_id
inner join `e-bookNew`.m_publisher ebmp on ebmp.publisher_id = '".$key."'
inner join `e-bookNew`.m_book ebmb on ebbs.book_id = ebmb.book_id
where ebmb.book_publisher='".$key."' group by ebbs.book_id)
UNION
(select
`ebookstore`.m_publisher.publisher_sname,`ebookstore`.m_publisher.publisher_id,`ebookstore`.tr_bookshelf.uni_id,`ebookstore`.tr_bookshelf.book_id,`ebookstore`.m_book.book_publisher,
`ebookstore`.dim_uni.uni_id,`ebookstore`.dim_uni.uni_name,
`ebookstore`.m_book.book_id,`ebookstore`.m_book.book_paperid,`ebookstore`.m_book.book_price,`ebookstore`.tr_bookshelf.order_time,`ebookstore`.m_book.book_title,`ebookstore`.m_book.book_install_date,
COUNT(`ebookstore`.tr_bookshelf.book_id) as countbs,SUM(`ebookstore`.m_book.book_price) as bookprices
from `ebookstore`.tr_bookshelf
inner join `ebookstore`.dim_uni on `ebookstore`.tr_bookshelf.uni_id = `ebookstore`.dim_uni.uni_id
inner join `ebookstore`.m_publisher on `ebookstore`.m_publisher.publisher_id = '".$key."'
inner join `ebookstore`.m_book on `ebookstore`.tr_bookshelf.book_id = `ebookstore`.m_book.book_id
where `ebookstore`.m_book.book_publisher='".$key."' group by `ebookstore`.tr_bookshelf.book_id)
LIMIT $Page_Start , $Per_Page
";
}