Between error query
Hi
I need help regarding this query
[QUOTE]SELECT `idsala`, `idtempoInicio`, `idTempoFim`, `data` FROM `req_material_reserva` WHERE `idsala` = 3 AND `idtempoInicio` BETWEEN = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-05"
Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where `idtempoInicio` between = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-0' at line 1 idtempo inicio fim ------- -------- ---------- 11 08:15:00 09:00:00 12 09:00:00 09:45:00 13 10:00:00 10:45:00 14 10:45:00 11:30:00 15 11:40:00 12:25:00 16 12:25:00 13:10:00 17 13:20:00 14:05:00 18 14:05:00 14:50:00 19 15:00:00 15:45:00 20 15:45:00 16:30:00 21 16:45:00 17:30:00 22 17:30:00 18:15:00 So i want to check if i can book between id 11 (inicio) and id 12(fim) for example, i must query the table idreserva idutilizador idsala idtempoInicio idTempoFim data idequipamento idfuncionario --------- ------------ ------ ------------- ---------- ---------- ------------- --------------- 9 1261 4 12 12 2014-05-05 (NULL) (NULL) 10 1261 4 11 11 2014-05-05 (NULL) (NULL) 11 1261 2 11 11 2014-05-05 (NULL) (NULL) 12 1261 3 11 11 2014-05-09 (NULL) (NULL) any help please??
Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where `idtempoInicio` between = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-0' at line 1 idtempo inicio fim ------- -------- ---------- 11 08:15:00 09:00:00 12 09:00:00 09:45:00 13 10:00:00 10:45:00 14 10:45:00 11:30:00 15 11:40:00 12:25:00 16 12:25:00 13:10:00 17 13:20:00 14:05:00 18 14:05:00 14:50:00 19 15:00:00 15:45:00 20 15:45:00 16:30:00 21 16:45:00 17:30:00 22 17:30:00 18:15:00 So i want to check if i can book between id 11 (inicio) and id 12(fim) for example, i must query the table idreserva idutilizador idsala idtempoInicio idTempoFim data idequipamento idfuncionario --------- ------------ ------ ------------- ---------- ---------- ------------- --------------- 9 1261 4 12 12 2014-05-05 (NULL) (NULL) 10 1261 4 11 11 2014-05-05 (NULL) (NULL) 11 1261 2 11 11 2014-05-05 (NULL) (NULL) 12 1261 3 11 11 2014-05-09 (NULL) (NULL) any help please??
-
Your query is not syntactically correct: SELECT `idsala`, `idtempoInicio`, `idTempoFim`, `data` FROM `req_material_reserva` WHERE `idsala` = 3 AND `idtempoInicio` BETWEEN = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-05"
When you use BETWEEN, you're literally saying "between two values". So it should be written as:BETWEEN X and X
You can find more info on this here: [url=http://www.tutorialspoint.com/mysql/mysql-between-clause.htm]MySQL BETWEEN Clause Please also consider asking your question on the MySQL forums, which is a more appropriate venue for this sort of issue.0 -
Hello :) Yes, as Vanessa mentioned, you will likely find more help on this topic on a forum where discussions of MySQL development/integration occurs. As it relates to MySQL, the forums here are more suited towards helping with the assistance/configuration/troubleshooting of the MySQL server, as opposed to MySQL scripting itself. Thank you. 0
Please sign in to leave a comment.
Comments
2 comments