Đã 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, t-sql with, t-sql in, car t com, t-sql;, statements, sql mysql, Sql code, statement structure sql, mysql select statement, php mysql sql example, sql select select, 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

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

Mã Dự Án: #1019724

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


I can help you with this.

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

HI! Please see PM, Regards, DiggitalBrains

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

pls check the pm

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

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

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

check pm please.

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

I can see what the problem is.

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