Link to home
Start Free TrialLog in
Avatar of MK15
MK15

asked on

mysql, view, ERROR 1242 (21000): Subquery returns more than 1 row

Hi can someone help me with this please,

i have a view where i am joining up several tables so is easier to query, i seem to be having this error stating subquery returns more than 1 row.

create view full_book_view as select b.book_id, b.book_title,b.isbn,b.retail_price, b.new_price, b.postage_price, b.description, b.quantity, b.book_condition
			    , (select group_concat(a.author) FROM book_authors as ba 
			    inner join author as a on ba.author_id = a.author_id
			    WHERE ba.book_id = b.book_id
			   GROUP BY ba.book_id) as Author,
			   (select group_concat(pub.publisher) from book_publishers as pb
			   inner join publisher as pub on pb.publisher_id = pub.publisher_id
			   where pb.book_id = b.book_id group by pb.book_id) as Publisher,
			   (select url from book_url as bu where bu.book_id = b.book_id)as url ,(select cust.username from customer as cust inner join users_per_book as upb on upb.customer_id = cust.customer_id where upb.book_id = b.book_id) as customer
			from books as b
			inner join book_categories as bc on bc.book_id = b.book_id
			inner join categories as cat on cat.cat_id = bc.category_id;

Open in new window


thanks
ASKER CERTIFIED SOLUTION
Avatar of johanntagle
johanntagle
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MK15
MK15

ASKER

Hi,
thanks a lot mate go rid of the error