MySQL Forums
Forum List  »  MySQL Query Browser

Simpleton requires help
Posted by: Christian Saunders
Date: August 05, 2012 07:07AM

Hello all,

I have a database:

The database is called "example".
There are two tables called "ticketlines" and "receipts".
In "ticketlines" there are three fields "ticket", "product" and "units".
In "receipts" there are two fields "id" and "datenew".
"ticket" and "id" are the same. They are related.

EXAMPLE
-TICKETLINES
--TICKET
--PRODUCT
--UNITS
-RECEIPTS
--ID
--DATENEW

I need to extract this:
The amount of "units" of "product" sold in the last 24 hours.

So far, my query is this:

SELECT product, units, ticket, id, datenew
FROM example.ticketlines, example.receipts
WHERE timediff(now(), datenew) < '24:00:00';

Which is a terrible failure and returns 1000 rows of data from a database that only has 43 rows.

Help a simpleton out, please!

Thanks,
Christian

Options: ReplyQuote


Subject
Written By
Posted
Simpleton requires help
August 05, 2012 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.