SQL syntax error: help a noob

2005-01-31 Thread Chris Kavanagh
Dear list,
My ColdFusion server tells me I have an error in my query syntax, but I 
can't work out what it is - because I'm working with code that someone 
very kindly gave me and I only have a vague idea of what the first 
line's doing!  Can anyone see the problem here?

SELECT DATEDIFF(leadtime_type, GETDATE(), deadline)'Difference',
		tasks.leadtime,
		tasks.lead_time_type_id,
		leadtime_type.leadtime_type
FROM tasks
		JOIN leadtime_type ON tasks.lead_time_type_id = 
leadtime_type.leadtime_type_id

Thanks in advance,
CK.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: SQL syntax error: help a noob

2005-01-31 Thread Roger Baklund
Chris Kavanagh wrote:
My ColdFusion server tells me I have an error in my query syntax, but I 
can't work out what it is - because I'm working with code that someone 
very kindly gave me and I only have a vague idea of what the first 
line's doing!  Can anyone see the problem here?

SELECT DATEDIFF(leadtime_type, GETDATE(), deadline)'Difference',
tasks.leadtime,
tasks.lead_time_type_id,
leadtime_type.leadtime_type
FROM tasks
JOIN leadtime_type ON tasks.lead_time_type_id = 
leadtime_type.leadtime_type_id
It would be helpfll if you told us what error message you got, and what 
version of MySQL you are using.

The only obvious error I can spot is GETDATE(), this is not a standard 
MySQL function. Try CURDATE().

--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: SQL syntax error: help a noob

2005-01-31 Thread Tom Crimmins
[snip]
My ColdFusion server tells me I have an error in my query syntax, but I
can't work out what it is - because I'm working with code that someone very
kindly gave me and I only have a vague idea of what the first line's doing!
Can anyone see the problem here?

SELECT DATEDIFF(leadtime_type, GETDATE(), deadline)'Difference',
tasks.leadtime,
tasks.lead_time_type_id,
leadtime_type.leadtime_type
FROM tasks
JOIN leadtime_type ON tasks.lead_time_type_id =
leadtime_type.leadtime_type_id
[/snip]

The datediff() function is new to version 4.1. What version of mysql are you
running?

---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: SQL syntax error: help a noob

2005-01-31 Thread Chris Kavanagh
Thanks very much for the replies, guys.  My version is 4.1.7-max.
The error message I get is:
--
Error Executing Database Query.
Syntax error or access violation: 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 ' deadline)'Difference',  tasks.leadtime,  
tasks.lead_time_type_id,  leadtime_' at line 1
--

I changed GETDATE() to CURDATE() but it still gives me the same error.  
Thanks for the suggestion anyway, Roger.

Best regards,
CK.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: SQL syntax error: help a noob

2005-01-31 Thread Tom Crimmins
I think datediff only takes two arguments and you have three listed.

---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa


-Original Message-
From: Chris Kavanagh
Sent: Monday, January 31, 2005 5:33 PM
To: mysql@lists.mysql.com
Subject: Re: SQL syntax error: help a noob

Thanks very much for the replies, guys.  My version is 4.1.7-max.

The error message I get is:
--
Error Executing Database Query.

Syntax error or access violation: 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 ' deadline)'Difference',  tasks.leadtime,
tasks.lead_time_type_id,  leadtime_' at line 1
--

I changed GETDATE() to CURDATE() but it still gives me the same error.  
Thanks for the suggestion anyway, Roger.

Best regards,
CK.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



SOLVED: SQL syntax error: help a noob

2005-01-31 Thread Chris Kavanagh
On 31 Jan 2005, at 11:39 pm, Tom Crimmins wrote:
I think datediff only takes two arguments and you have three listed.
Nailed it!  Thanks, Tom.
Best regards,
CK.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]