On 9/7/2005 1:17 PM Ryan Stille intelligently wrote:
> I am migrating from MS SQL Server to MySQL 4.1.
> 
> I have code in my ColdFusion/SQL Server application that went something
> like this:
> <cfquery name="insertquery">
> SET NOCOUNT ON
> INSERT INTO TABLE (....)
> SELECT @@IDENTITY AS adid
> SET NOCOUNT OFF
> </cfquery>
> 
> That whole block was processed in coldfusion as a single query.  I gave
> it a name of "insertquery", and I can get the ID back as
> insertquery.adid.
> 
> I am having trouble getting the same functionality with MySQL.
> <cfquery name="insertquery">
> INSERT INTO TABLE (...)
> SELECT LAST_INSERT_ID() as adid
> </cfquery>
> 
> I get this MySQL error:
> 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 'INSERT
> INTO rps_names (nameid, name) VALUES (NULL, "Ryan Smithland") SELECT LA'
> at line 2
> 
> With MSSQL the trick was the NO COUNT.  That told the database server
> not to return a count of the rows affected.  Is there something similar
> I need to do in MySQL to get this to work?
> 
> Thanks,
> -Ryan
> 

it might be best to ask this in the cf forums, however did you try to
separate the statements with a ; ? I haven't tried 2 query statements
for MySQL in cfquery...yet ;-) Also I believe MySQL 3.23+ supports
@@identity

HTH, Tim

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

Reply via email to