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

  • SEARCH
  • Home
  • 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 8775493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:48:43+00:00 2026-06-13T18:48:43+00:00

I have follow query notes = Note.where(‘notes.id IN ( SELECT notes.id FROM notes WHERE

  • 0

I have follow query

  notes = Note.where('notes.id IN
  (
    SELECT "notes"."id" FROM "notes" 
      WHERE "notes"."circle_id" = ?
  )
  OR notes.id IN 
  (
    SELECT "notes"."id" FROM "notes" 
      INNER JOIN "circles_dreams" 
      ON "circles_dreams"."dream_id" = "notes"."dream_id" 
      WHERE "circles_dreams"."circle_id" = ? 
  )', @circle.id, @circle.id)

How to simplify this query?
Thanks.

  • 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-13T18:48:44+00:00Added an answer on June 13, 2026 at 6:48 pm

    First of all you can collect all needed notes id.
    I supposed to think what you already have relations between Note and CirclesDream

    note_ids = Note.where(circle_id: @circle.id).pluck(:id) # your first SELECT
    dream_ids = CirclesDream.where(id: @circle.id).pluck(:note_id) # your second SELECT
    
    notes_ids = note_ids | dreams_ids # combine them
    
    notes = Note.where(id: notes_ids) # Now your
    

    upd: I’ve just fixed typo. Changed id to note_id in second request

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

Sidebar

Related Questions

I have the follow query: SELECT pro.* FROM tb_AutProposta pro, tb_AutParcelamento par WHERE pro.id
I have a record that came from the follow linq query: using (var context
I have the cursor with the query statement as follows: cursor.execute(select rowid from components
I have this query: (from r in gServiceContext.CreateQuery(opportunity) join c in gServiceContext.CreateQuery(contact) on ((EntityReference)r[new_contact]).Id
I have a mysql problem, my query looks as follows but not complete SELECT
I have the following SQL query: SELECT CountryID, [10201] AS CountryGDPPerCapita, [10677] AS LifeExpTotal
In my model I have the follow query: function myquerydata() { $data = array();
I have my MDX query as follow: with set SelectedEntity as '{Union({[Category].[Tertiary Category].Members}, {[Category].[Secondary
I have a simple HTML Form as follow (form.html) : <form id=tips-message-notes action=notessaved.php method=post
I have a query as follows: String SQL = insert into table (id, name)

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.