•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,628 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,804 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 1340 | Replies: 5
![]() |
•
•
Join Date: May 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Hey guys, im in deep need of help for mysql. Ive been given a few questions most of them answered although theres 3 which are really bringing me down. I was wondering if u could get some help 
Given this schema
borrow(transactionID, personID*, borrowdate, duedate, returndate)
author(authorID, firstname, middlename, lastname)
book_copy(bookID, bookdescID*)
book(bookdescID, title, subtitle, edition, voltitle, volnumber, language, place, year, isbn, dewey, subjectID*)
borrow_copy(transactionID*, bookID*)
person(personID, firstname, middlename, lastname, address, city, postcode, phonenumber, emailaddress, studentno, idcardno)
publisher(publisherID, publisherfullname)
written_by(bookdescID*, authorID*, role)
published_by(bookdescID*, publisherID*, role)
subject(subjectID, subjecttype)
1. i need to display the firstname and lastname of the people who returned books more than 7 days late.
-i tried using the datediff function although it came back as invalid, is there another way?
2. A borrower wants to borrow the book titled "PRINCIPLES AND PRACTICE OF DATABASE SYSTEMS", but finds out all of its copies are already borrowed by others. Write two queries to display other recommended titles using the following methods.
and my last one
3. i have to display the title of the book which has most physical copies. If there are more than one book with the largest number of copies, show them all. Your query should show the number of copies along with the title.
-eh? lol
Help with these would be great, describing what you did would be a bonus but then again i'm asking for too much. Any help would be appreciated. Thankyou
N

Given this schema
borrow(transactionID, personID*, borrowdate, duedate, returndate)
author(authorID, firstname, middlename, lastname)
book_copy(bookID, bookdescID*)
book(bookdescID, title, subtitle, edition, voltitle, volnumber, language, place, year, isbn, dewey, subjectID*)
borrow_copy(transactionID*, bookID*)
person(personID, firstname, middlename, lastname, address, city, postcode, phonenumber, emailaddress, studentno, idcardno)
publisher(publisherID, publisherfullname)
written_by(bookdescID*, authorID*, role)
published_by(bookdescID*, publisherID*, role)
subject(subjectID, subjecttype)
1. i need to display the firstname and lastname of the people who returned books more than 7 days late.
-i tried using the datediff function although it came back as invalid, is there another way?
2. A borrower wants to borrow the book titled "PRINCIPLES AND PRACTICE OF DATABASE SYSTEMS", but finds out all of its copies are already borrowed by others. Write two queries to display other recommended titles using the following methods.
- Using partial matching of the query string -- note that the borrower is interested in a "DATABASE" book.
- By searching of other books borrowed by people who also borrowed the above title
and my last one
3. i have to display the title of the book which has most physical copies. If there are more than one book with the largest number of copies, show them all. Your query should show the number of copies along with the title.
-eh? lol
Help with these would be great, describing what you did would be a bonus but then again i'm asking for too much. Any help would be appreciated. Thankyou
N
•
•
Join Date: Mar 2007
Posts: 28
Reputation:
Rep Power: 0
Solved Threads: 0
That's almost right! It looks like you're using sql server syntax. MySql's DateDiff() function works a little differently.
So it doesn't require the interval ("dd" - for days). Try instead
•
•
•
•
DATEDIFF(expr1,expr2)
DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
http://dev.mysql.com/doc/refman/4.1/...ction_datediff
So it doesn't require the interval ("dd" - for days). Try instead
where datediff(returndate, dueDate) > 7;
•
•
Join Date: May 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
where person.personid = borrow.personid and datediff(returndate, dueDate) > 7
*
ERROR at line 3:
ORA-00904: "DATEDIFF": invalid identifier
Thats what i got, i dont think i can use the function at all. Should i nest it, so it becomes less sensitive?
I might just skip this one, given me enough problems already. Could you help me with the next two cfAllie
your expertise is in need haha
*
ERROR at line 3:
ORA-00904: "DATEDIFF": invalid identifier
Thats what i got, i dont think i can use the function at all. Should i nest it, so it becomes less sensitive?
I might just skip this one, given me enough problems already. Could you help me with the next two cfAllie
your expertise is in need haha •
•
Join Date: Mar 2007
Posts: 28
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
where person.personid = borrow.personid and datediff(returndate, dueDate) > 7
*
ERROR at line 3:
ORA-00904: "DATEDIFF": invalid identifier
Thats what i got, i dont think i can use the function at all. Should i nest it, so it becomes less sensitive?
I might just skip this one, given me enough problems already. Could you help me with the next two cfAllieyour expertise is in need haha
I think you may posted this question in the wrong forum. Its under MySql db, but it looks like you're using Oracle. Unfortunately, I'm not and don't know Oracle syntax
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- Where to begin? Any help is much appreciated! (Software Developers' Lounge)
- Any help would be greatly appreciated :) (Java)
- Help appreciated on a display problem (Windows 9x / Me)
- Any help on my dead Satellite A20 would be greatly appreciated! (Troubleshooting Dead Machines)
- Suggestion appreciated. (Promotion and Marketing Plans)
- Help appreciated/required for project (Java)
- Help would be appreciated concerning task manager (Windows NT / 2000 / XP / 2003)
- Any help will be greatly appreciated... (Viruses, Spyware and other Nasties)
- NEW Site: Feedback Greatly Appreciated (Website Reviews)
- An Interesting Evolution of Problems, Suggestions Appreciated (Troubleshooting Dead Machines)
Other Threads in the MySQL Forum
- Previous Thread: Static Count vs Dynamic Count (Very advanced, gurus take your shot)
- Next Thread: import Ms excel to ysql


we were never properly taught to use datediff, so im a tad confused
Linear Mode