Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:30:37+00:00 2026-06-11T16:30:37+00:00

view: <% Favorite.find_by_sql(SELECT p.* FROM favorites as f LEFT JOIN posts as p ON

  • 0

view:

<% Favorite.find_by_sql("SELECT p.* FROM favorites as f LEFT JOIN posts as p ON p.user_id = f.user_id WHERE f.user_id = ? limit 15", @user.id).reverse.each do |post| %>

i am getting the following error:

Mysql2::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 '? limit 15' at line 1: SELECT p.* FROM favorites as f LEFT JOIN posts as p ON p.user_id = f.user_id WHERE f.user_id = ? limit 15

what i am basically trying is to get posts the i have favorited

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:30:38+00:00Added an answer on June 11, 2026 at 4:30 pm

    Try

    <% Favorite.find_by_sql(["SELECT p.* FROM favorites as f LEFT JOIN posts as p ON p.user_id = f.user_id WHERE f.user_id = ? limit 15", @user.id]).reverse.each do |post| %>
    

    Need to send the query and it’s parameters as an array to get the argument replace occurring.

    Are you aware this method is deprecated, not db agnostic so an absolute last resort and a maintenance nightmare.

    Should be a method on your model to do this, putting sql in a view is not just going off the rails it’s a catastrophic train wreck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pushing 2 view controllers in to navigation stack in ApplicationDidFinishLaunching. [navigationController pushViewController:favorites
I am trying to pass a random string from my Controller to the View
What do you prefer (from your developer's point of view) when it comes to
I'm making a game link site, where users can post links to their favorite
I have 6 list items $('.favorite-tag-group li').each(function(){ console.log(hi); }); This code however is displaying
I need to check is the current post in users favorites list something like(in
I have table view that showing hotels and if they favorite or not. If
I'm trying to display data from my database in a Codeigniter view. Seems like
View History on an file in a branch show only changes since the branch.
View Looks Like This <?=form_open_multipart('upload/process');?> <input type=file multiple=multiple name=userfile[] id=userfile /> <?=form_submit('upload', 'Upload');?> <?=form_close();?>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.