Annulé

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

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 ont fait une offre moyenne de 33 $ pour ce travail

smartgest

I can help you with this.

30 $ USD en 0 jours
(11 Commentaires)
5.0
diggitalbrains

HI! Please see PM, Regards, DiggitalBrains

30 $ USD en 1 jour
(15 Commentaires)
4.6
sadeque

pls check the pm

30 $ USD en 1 jour
(12 Commentaires)
4.4
oFAZo

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

45 $ USD en 0 jours
(4 Commentaires)
4.2
neoabd

check pm please.

30 $ USD en 0 jours
(0 Commentaires)
0.0
eroteme

I can see what the problem is.

30 $ USD en 0 jours
(0 Commentaires)
0.0