tags:

views:

51

answers:

1

How can i simplify this code. coz this uses subquerying

SELECT ub.id_product as c_pid,DATE(ub.datetime_prchs)AS datePurchased,cb.bookname, 
(SELECT GROUP_CONCAT(c.userid ORDER BY c.userid ASC SEPARATOR ', ')  FROM 
user_books ub 
INNER JOIN campus_bookinfo cb ON ub.id_product=cb.idx_campus_bookinfo 
LEFT JOIN customer c ON ub.id_customer=c.id_customer 
WHERE ub.id_product = c_pid 
)as buyer,
cb.iAmount FROM user_books ub 
INNER JOIN campus_bookinfo cb ON ub.id_product=cb.idx_campus_bookinfo 
LEFT JOIN customer c ON ub.id_customer=c.id_customer 
WHERE ub.id_customer = 29
GROUP BY bookname
ORDER BY ub.datetime_prchs

I need a better code for the same output.. Thanks in advance

A: 

please close this question.. information not needed anymore.. thanks

Treby