Đã Hủy

SQL statements EXPERT

OK, so I have the the following table structure: [url removed, login to view]

When I go to [url removed, login to view] and try to add a reservation with start date/time 2011-04-11 03:00:00 and end date/time 2011-04-23 05:00:00 for car 1, it shouldn't let me do it because it will conflict with the reservation that's already there.

In my PHP code, when I try to add a new reservation, the following code is executed:

$sql = 'SELECT id FROM ' . $config['tbl_prefix'] . 'reservations WHERE car_id = ' . $car_id . ' AND \'' . $start_date . ' ' . $start_time . '\' BETWEEN start_datetime AND end_datetime AND \'' . $end_date . ' ' . $end_time . '\' BETWEEN start_datetime AND end_datetime';

For the example stated above, the query would be:

SELECT id FROM corfu44_reservations WHERE car_id = 1 AND '2011-04-11 03:00:00' BETWEEN start_datetime AND end_datetime AND '2011-04-23 05:00:00' BETWEEN start_datetime AND end_datetime

It looks right but it's not doing exactly what I want.

So what I need is basically a SQL statement that will prevent me from entering any reservation that conflicts with any of the available reservations.

Kỹ năng: MySQL, SQL

Xem thêm: car reservations, car id, statements, sql mysql, sql code, statement structure sql, mysql select statement, php mysql sql example, sql select, car reservation php, add sql php, reservation table php, end expert, mysql config, car test, reservation table, reservation code, php mysql statement, mysql statement, expert test, mysql query example, sql expert need, table reservation, reservation mysql query, car reservation example

Về Bên Thuê:
( 4 nhận xét ) Chorrillos, Peru

Mã Dự Án: #1019724

7 freelancer đang chào giá trung bình $32 cho công việc này

hvtuananh

Please check your PMB

$30 USD trong 0 ngày
(63 Đánh Giá)
6.1
smartgest

I can help you with this.

$30 USD trong 0 ngày
(11 Đánh Giá)
5.0
diggitalbrains

HI! Please see PM, Regards, DiggitalBrains

$30 USD trong 1 ngày
(15 Đánh Giá)
4.6
sadeque

pls check the pm

$30 USD trong 1 ngày
(12 Đánh Giá)
4.4
oFAZo

Exceptional quality & Quick work. Please refer to Profile & Reviews for details. Thanks FAZ

$45 USD trong 0 ngày
(4 Đánh Giá)
4.2
neoabd

check pm please.

$30 USD trong 0 ngày
(0 Đánh Giá)
0.0
eroteme

I can see what the problem is.

$30 USD trong 0 ngày
(0 Đánh Giá)
0.0