Skip to content

Instantly share code, notes, and snippets.

@heijmerikx
Created October 4, 2011 08:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save heijmerikx/1261118 to your computer and use it in GitHub Desktop.
Save heijmerikx/1261118 to your computer and use it in GitHub Desktop.
MySQL FIND_IN_SET to Postgresql...
def self.order(ids)
# The postgresql way
update_all(["position = STRPOS(?, ','||id||',')", ",#{ids.join(',')},"], { :id => ids })
# the mysql way
# update_all(['position = FIND_IN_SET(id, ?)', ids.join(',')],{ :id => ids })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment