Skip to content

Instantly share code, notes, and snippets.

@advorak
Created October 18, 2010 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save advorak/632657 to your computer and use it in GitHub Desktop.
Save advorak/632657 to your computer and use it in GitHub Desktop.
params[:id] = 1
Artist.where("lastname LIKE '(?)*'",params[:id])
# This generates the following query:
# SELECT "artists".* FROM "artists" WHERE (lastname LIKE '('a')*')
# Note how you don't want the apostrophe within your "where" query ...
Artist.where("lastname LIKE ?",params[:id])
# The above generates:
# SELECT "artists".* FROM "artists" WHERE (lastname LIKE 'a')
# Now this doesn't solve your problem, but it might give you a starting point toward a solution..
Artist.where("username LIKE ?","a%")
# Might be what you're looking for?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment