Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Functions PARTITION BY convert to MySQL

Author  Topic 

monaya
Yak Posting Veteran

58 Posts

Posted - 2009-06-04 : 15:31:15
Can someone help convert this properly to MySQL. I'm getting an error around partition when i run the SQL.

error: right syntax to use near '(Partition By accountID Order By accountID, bookID from rentals ' at line 5

create function GetNumberOfRentalsCurrentlyAllowed(accountID int)
returns int

begin
return (select accttype from Account_Types where accountID= accountID) - (select Row_NUMBER() Over (Partition By accountID Order By accountID, bookID
from rentals
where accountID = @accountID and checkedout=1 and checkedin=0), 0)
end

create VIEW RentalsRequested
as
select *, Row_NUMBER() Over (Partition By accountID Order By accountID, bookID) as numberOfRentalsRequested
from rentals
WHERE Rentals.checkedout = 0 AND Rentals.checkedin = 0

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-04 : 15:41:08
I think MySQL has no row_number() at this time.
Here is a hint from google
http://www.xaprb.com/blog/2005/09/27/simulating-the-sql-row_number-function/


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

wonn1377
Starting Member

3 Posts

Posted - 2009-08-21 : 10:20:24
I think u should use a third party help to resolve this problem, i use dbload to solve it when i was migrated my data, it can migrate almost any data, it helps me to convert MSSQL to MYSQL, MS access to MSSQL, mysql, csv loader, foxpro and MSSQL to MS access, MYSQl, CSV, foxpro etc. i found it on google search.


Download Free : http://www.dbload.com
Go to Top of Page
   

- Advertisement -