473,669 Members | 2,372 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(attendanc e.staffid) AS Work
FROM attendance
INNER JOIN staff ON ' at line 10
Oct 9 '14 #1
2 1062
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
2123
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 user presses the login-button (I can't change that setup). If the login is not correct I want to display the login form again and show an additional line displaying the error, that is easy and already working.
0
1419
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 order such that I get a bunch a foreign key constraints. Even if I use the MysqlPhp admin tool, Mysql Manager, SqlYog, it doesn't work: they make an export of the db structure but the db structure, that consists of create table statements, isn't...
1
12787
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? System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not...
27
2973
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 of good examples I came up with the idea of solving the puzzle explained in code below, with the solver optimized so that a state is never analysed more than once. However, I soon realized that this could be done most naturally (for me, at...
17
2404
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 name="a"> <input type=text name="b"> </div>
102
5649
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 can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
27
2296
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: http://www.johnjsal.devisland.net/switches.jpg Here's the situation: Each of the four rows in the diagram is considered a single 'panel'. Each panel has eight 'switches', which are composed of two columns each, and these columns have a total of 20...
6
1490
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 there a correct way? Thanks for the help.
14
11890
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 doing something was really inefficient and could reduce 10 lines of code with 2, etc. For reading, I am using a TcpClient and I call NetworkStream ns = client.GetStream(); to get a stream stream.Read(buffer, 0, buffer.Length);
3
1313
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
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8894
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.