2007-10-30, 09:39 PM
Hi all,
It's been some time since i've been here. I stopped coding for almost a year now. But now I started again with some website and I have a problem with the database. I hope one of you can help me out.
I have for example 2 tables. One containing users:
uid, username, email, ....
And one containing book information that users uploaded in a form:
bid, title, genre, owner, ... (and owner is the uid of the user who uploaded it)
Now I try to make a list of all the books with their corresponding owners.
I'm using this query: SELECT b.*, u.username, u.uid FROM books b, users u WHERE b.owner=u.uid ORDER BY b.title ASC
I've set it so that users can choose how they want the books to be ordered (genre, title, bid, username,..., ASC, DESC). And when you click on the title, you get to a page with details on the book (found using bid). Up to here everything works as it should:
# Title Owner
1 The Lord of The Rings Bob
2 Harry Potter 1 Bob
3 Harry Potter 2 Alan
BUT if someone enters a book with the exact same title as someone else, I want it to show as ONE row and not as two, the owner column is not necessarily needed.
# Title Owner
1 The Lord of The Rings Bob
2 Harry Potter 1 Alan
3 Harry Potter 1 Bob
These last two rows should be merged into one. I don't think it's possible. But if it is, how could I do it?
Maybe I'll just need to show the titles only without anything else, but then I can't have the users sort them.
It's been some time since i've been here. I stopped coding for almost a year now. But now I started again with some website and I have a problem with the database. I hope one of you can help me out.
I have for example 2 tables. One containing users:
uid, username, email, ....
And one containing book information that users uploaded in a form:
bid, title, genre, owner, ... (and owner is the uid of the user who uploaded it)
Now I try to make a list of all the books with their corresponding owners.
I'm using this query: SELECT b.*, u.username, u.uid FROM books b, users u WHERE b.owner=u.uid ORDER BY b.title ASC
I've set it so that users can choose how they want the books to be ordered (genre, title, bid, username,..., ASC, DESC). And when you click on the title, you get to a page with details on the book (found using bid). Up to here everything works as it should:
# Title Owner
1 The Lord of The Rings Bob
2 Harry Potter 1 Bob
3 Harry Potter 2 Alan
BUT if someone enters a book with the exact same title as someone else, I want it to show as ONE row and not as two, the owner column is not necessarily needed.
# Title Owner
1 The Lord of The Rings Bob
2 Harry Potter 1 Alan
3 Harry Potter 1 Bob
These last two rows should be merged into one. I don't think it's possible. But if it is, how could I do it?
Maybe I'll just need to show the titles only without anything else, but then I can't have the users sort them.