Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Between error query

Discussion in 'General Discussion' started by alphasil, May 3, 2014.

  1. alphasil

    alphasil Member

    Joined:
    May 3, 2014
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Website Owner
    Hi

    I need help regarding this query


    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??
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    834
    Likes Received:
    29
    Trophy Points:
    178
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Your query is not syntactically correct:

    Code:
     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:

    Code:
    BETWEEN X and X
    
    You can find more info on this here:

    MySQL BETWEEN Clause

    Please also consider asking your question on the MySQL forums, which is a more appropriate venue for this sort of issue.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice