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.

Compétences : MySQL, SQL

en voir plus : 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

Concernant l'employeur :
( 4 commentaires ) Chorrillos, Peru

Nº du projet : #1019724

6 freelance font une offre moyenne de $33 pour ce travail


I can help you with this.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(11 Commentaires)

HI! Please see PM, Regards, DiggitalBrains

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(15 Commentaires)

pls check the pm

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(12 Commentaires)

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

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(4 Commentaires)

check pm please.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(0 Commentaires)

I can see what the problem is.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(0 Commentaires)