Answer the question
In order to leave comments, you need to log in
How are prices implemented?
Good afternoon. Essence of the question: There is a database, we enter into it information about what a person bought on 05/01/2015 (let's call it a CHECK):
Answer the question
In order to leave comments, you need to log in
There is an orders table. in it what kind of person, contacts, date of purchase.
For example:
id | name | date
------------------
17| Vasily | 05/01/2015
There is a table purchases, in it line by line what kind of purchase, price, and the main identifier from the orders table. That is, three purchases = three entries.
id | order_id | price | name
------------------------------
1 | 17 | 100 | Tractor
2 | 17 | 200 | Bicycle
3 | 17 | 300 | Pot
If the base, let's say sql, then a query is made like this:
select o.name as fio, o.date, p.price, p.name as product_name from orders o inner join purchases p ON(o.id=p.order_id) where o.date='05/01/2015'
we get the following output:
fio | date | price | product_name
--------------------------------
Vasily | May 01, 2015 | 100 | Tractor
Vasily | May 01, 2015 | 200 | Bicycle
Vasily | May 01, 2015 | 300 | Pot
You don't have to drag anything out of o.* if you only want the price tag for the date. Or use between in the condition if you need a selection for a range of dates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question