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 8529913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:08:15+00:00 2026-06-11T09:08:15+00:00

I am attempting to construct a join as follows: UserLog.find(:all, :joins => JOIN client_inspector

  • 0

I am attempting to construct a join as follows:

UserLog.find(:all, :joins => " JOIN client_inspector ON user_log.COMPUTER_NAME = client_inspector.Retrieving_Hostname ", :select=>  "DISTINCT user_log.COMPUTER_NAME, client_inspector.Retrieving_Hostname ")

But its giving me the following error ->

ActiveRecord::StatementInvalid (Mysql2::Error: Table 'user_log.client_inspector' doesn't exist: SELECT DISTINCT user_log.COMPUTER_NAME, client_inspector.Retrieving_Hostname  FROM `user_log` JOIN client_inspector ON user_

log.COMPUTER_NAME = client_inspector.Retrieving_Hostname):

I understand the MYSQL error, but why is Rails doing this?

I do not have any Models created associating these two tables together. What I’d like to do is to be able to join via different columns other than the defaults that Ruby builds in.

Is there a different way to do this?

EDIT: I updated to include my actual table names.

  • 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-11T09:08:16+00:00Added an answer on June 11, 2026 at 9:08 am

    Anyone looking for the answer to this, just use this to grab your data ->

    @returned_fields = ActiveRecord::Base.connection.execute(sql)
    

    This will not return “Model” objects, but just a generic MySQL::Result object. Use this to get the data ->

    @returned_fields.each
    

    This will give you an array of arrays like so ->

    [[1,2], [3,4], etc...]
    

    Also, make sure you qualify your tables with the database name like so ->

    SELECT foo FROM database.BAR as bar JOIN database.BLEZ as blez ON bar.COMPUTER_NAME = blez.Retrieving_Hostname
    

    My problem turned out to be the qualifying of the database. Since I didn’t qualify, it was looking for the table in the wrong database (the one I was connected to currently).

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

Sidebar

Related Questions

I am attempting to construct my own date picker using code from several sources.
I am attempting to construct my own date picker using code from several sources.
I'm attempting to use a Model but I get a fatal error so I
I am attempting to construct a formview that will edit two related objects at
I'm attempting to construct rich-text where the first part says Looking for: and is
I know this is strange but I'm just having fun. I am attempting to
I am attempting to construct a very simple proof of concept that I can
I'm attempting to construct a suffix trie, and due to strict requirements it must
I am attempting to construct a component tree in JSF 1.2 (Mojarra) where the
I'm attempting to construct a web service that allows for RESTful requests to return

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.