TripleDeal TripleDeal - 2 months ago 10
MySQL Question

MySQL query failed to run - MySQL error: #1064

I'm getting the error:


#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 ' dag = zaterdag, start = 15, start_minuten = 00, eind = 19,
eind_minuten = 00, d' at line 1


when I try to run this query in Phpmyadmin:

SELECT * FROM rooster WHERE medewerker = 00126311, dag = zaterdag, start = 15, start_minuten = 00, eind = 19, eind_minuten = 00, datum = 2016-09-17, weeknummer = 37, leiding = 0


My table (rooster) structure:

id int(4)
medewerker varchar(10)
dag varchar(10)
start varchar(25)
start_minuten varchar(25)
eind varchar(25)
eind_minuten varchar(25)
datum date
weeknummer int(2)
leiding int(1)


medewerker is inner joined with another table, it shows the employee's number.

translation:
zaterdag means saturday
medewerker means employee
dag means day
minuten means minutes
datum means date
weeknummer mean weeknumber
leiding means boss (if boss is 1, he's the boss on that day)

I will appreciate it if someone could help me with this problem.

Answer

Can you please try with this: you also have to enclose values in single quotes if datatype is VARCHAR or CHAR

SELECT * 
FROM rooster 
WHERE medewerker = '00126311' 
    AND dag = 'zaterdag'
    AND start = '15'
    AND start_minuten = '00'
    AND eind = '19'
    AND eind_minuten = '00' 
    AND datum = '2016-09-17'
    AND weeknummer = 37 
    AND leiding = 0
Comments