I am so lost in this situation and badly need a help. The case is this. I copy a data value from a table, let say table book_book So i use:
INSERT INTO book_copy(name,qty,price,year,isbn)
SELECT bb.name,bb.qty,bb.price,bb.total,bb.year
FROM book_book bb WHERE ss.name = 'sample PR' and ss.isbn = 'PH019BN'
what the output showed me was:
name | qty | price | year | isbn
sample PR | 4 | | | PH019BN
sample PR | | 20.00 | | PH019BN
sample PR | | | 1991 | PH019BN
but i what i want is to view it as:
name | qty | price | year | isbn
sample PR | 4 | 20.00 | 1991 | PH019BN
Any help is much appreciated...
What you're looking for is called "pivoting". From your example data, it looks like
nameandisbnare always filled in, andqty,price, andyearin one row only. You can pivot that like: