[Situation:] In table 1, the {code...} of the bicycle number tenant seller [indicates that different sellers. Bicycle owned by sellers] Table 2 Rental Amount of bicycle number rental time {code...} [meaning here. Different merchants have their own bicycles... [the situation is as follows]
In table 1
Bicycle number tenant merchant
1 a 2 a3 b4 c
[This means that different merchants. Bicycles owned by sellers]
Table 2
Bicycle No. Rental time Rental Amount
1 2 41 3 51 6 102 3 53 4 7
[This means. The price and price list set by different merchants for the rental time of their bicycles]
Table 3
The person who rented the bicycle number at the time of rental
1 2 users 11 3 users 22 4 users 33 2 users 44 1 user 5 [here, users, bicycles and rental time used today, car rental records]
[So the question is coming]
I want to know
1. Merchants rent a car today, with the same 1 car, total number of times of renting a car
Finally, you need to get
How many times does a bicycle number be rented out in 2 hours? How many times do I rent out three hours? How many times have I rented out for 4 hours?
I have 2 methods. The first is to use a program to first identify the rental records of all vehicles. Then, the program is used to calculate the rental time and the number of times.
This type of data statistics. In general, how can PHP achieve efficiency. And can be very concise!
Reply content:
[Situation]
In table 1
Bicycle number tenant merchant
1 a 2 a3 b4 c
[This means that different merchants. Bicycles owned by sellers]
Table 2
Bicycle No. Rental time Rental Amount
1 2 41 3 51 6 102 3 53 4 7
[This means. The price and price list set by different merchants for the rental time of their bicycles]
Table 3
The person who rented the bicycle number at the time of rental
1 2 users 11 3 users 22 4 users 33 2 users 44 1 user 5 [here, users, bicycles and rental time used today, car rental records]
[So the question is coming]
I want to know
1. Merchants rent a car today, with the same 1 car, total number of times of renting a car
Finally, you need to get
How many times does a bicycle number be rented out in 2 hours? How many times do I rent out three hours? How many times have I rented out for 4 hours?
I have 2 methods. The first is to use a program to first identify the rental records of all vehicles. Then, the program is used to calculate the rental time and the number of times.
This type of data statistics. In general, how can PHP achieve efficiency. And can be very concise!
This can be solved directly by using SQL statements. You can use the left join to find any data you want. If you use php to process it, retrieve all the data at a time, it is also possible to process the database again. Do not query the database again in a loop.