473,508 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i solve and how to fix to correct?

1 New Member
This following is my code

Expand|Select|Wrap|Line Numbers
  1. SELECT staff.staffid, 
  2. staff.name, 
  3. attendance.checkintime, 
  4. attendance.checkouttime, 
  5. attendance.breakintime, 
  6. attendance.breakouttime, 
  7. attendance.latetime, 
  8. attendance.overtime, 
  9. attendance.transfees, 
  10. COUNT (paidvacation.staffid) AS Leave, 
  11. COUNT(attendance.staffid) AS Work 
  12. FROM attendance 
  13. INNER JOIN staff ON (staff.staffid = attendance.staffid) 
  14. INNER JOIN paidvacation ON (paidvacation.staffid = attendance.staffid) 
  15. WHERE (attendance.createdate>='$startdate' AND attendance.createdate<='$lastdate') GROUP BY attendance.staffid;
ERROR formed

#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 'Leave,
COUNT(attendance.staffid) AS Work
FROM attendance
INNER JOIN staff ON ' at line 10
Oct 9 '14 #1
2 1056
amnos
3 New Member
seems to be that you have extra space between
Expand|Select|Wrap|Line Numbers
  1. COUNT (paidvacation.staffid) 
count and open braces remove it and check,

Expand|Select|Wrap|Line Numbers
  1. SELECT staff.staffid,staff.name,attendance.checkintime,attendance.checkouttime,attendance.breakintime,attendance.breakouttime,
  2. attendance.latetime,attendance.overtime,attendance.transfees,COUNT(paidvacation.staffid) AS Leave,COUNT(attendance.staffid) AS Work
  3. FROM attendance INNER JOIN staff ON (staff.staffid = attendance.staffid) INNER JOIN paidvacation ON (paidvacation.staffid = attendance.staffid)
  4. WHERE (attendance.createdate>='$startdate' AND attendance.createdate<='$lastdate') GROUP BY attendance.staffid;
Oct 9 '14 #2
Luuk
1,047 Recognized Expert Top Contributor
the problem is that LEAVE is a reserved word

Because of this it should not be used as an alias, or you should put double quotes around it:
Expand|Select|Wrap|Line Numbers
  1. [root@test]> select 1 Leave;
  2. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Leave' at line 1
  3. [root@test]> select 1 "Leave";
  4. +-------+
  5. | Leave |
  6. +-------+
  7. |     1 |
  8. +-------+
  9. 1 row in set (0.00 sec)
  10.  
  11.  
Oct 11 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2110
by: Joe Randstein | last post by:
Hi! I need the best way to solve a problem, I'm a newbie. I have "login.php", a login script. That page first displays a login form with itself as target of a post-request to validate data when...
0
1409
by: Eddie Post | last post by:
Hellu, I want to transfer the structure of my InnoDb database to another mysql server 3.23. However, I don't seem to get this to work correctly as the tables are not transfered in the correct...
1
12776
by: BVM | last post by:
Hi, All: I have this error. It seems execution time is too long. Actually the execution time is about 30 seconds(I tested in Query analyzer). How do I solve this problem? ...
27
2951
by: Alf P. Steinbach | last post by:
I'm writing a little piece on pointers, to be "bundled" with my attempted correct C++ tutorial (see FAQ item 29.20, yes, I've finally started to at least think about that again), and while thinking...
17
2393
by: eric.nave | last post by:
What is the correct way to find all the form elements in a particular div? I'd like to be able to loop through them and disable them. For example: <form> <div id="div1"> <input type=text...
102
5572
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
27
2275
by: John Salerno | last post by:
Ok, here's a problem I've sort of assigned to myself for fun, but it's turning out to be quite a pain to wrap my mind around. It's from a puzzle game. It will help if you look at this image: ...
6
1473
by: VMI | last post by:
What's the correct way of using try...catch in my web application? For example, if I catch a connection error or something with the DB, how am I supposed to bubble it up to the web interface? Is...
14
11861
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
3
1300
by: stdvu | last post by:
What will be the output of the following expression: ((a >> b) ^ c)& d Where a = 12, b =2, c = 5 and d = 2 Ans ===> 010 (binary form) 2 (decimal form)
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.