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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:24:07+00:00 2026-06-16T02:24:07+00:00

How do you perform a joins in CakePHP like for example the one below

  • 0

How do you perform a joins in CakePHP like for example the one below for MySQL?

SELECT *
FROM yarns y
JOIN yarn_brands yb
JOIN contents ct
WHERE y.id = ct.yarn_id
AND yb.id = y.yarn_brand_id
AND ct.material_id = 2

I have tried to search around for the answer but i dont find anything that works.
I found something about “contain”, i have tried this but i get the result that the query it produces doesent include a join of the table requested to join in.

$this->Message->find('all', array(
    'contain' => array('User')
    'conditions' => array(
        'Message.to' => 4
    ),
    'order' => 'Message.datetime DESC'
));
  • 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-16T02:24:09+00:00Added an answer on June 16, 2026 at 2:24 am

    This is the join i ended up with:

                $options['contain'] = '';
                $options['joins'][0]['table'] = 'contents';
                $options['joins'][0]['alias'] = 'cont';
                $options['joins'][0]['conditions'] = 'Yarn.id = cont.yarn_id';
                $options['joins'][1]['table'] = 'yarn_brands';
                $options['joins'][1]['alias'] = 'yb';
                $options['joins'][1]['conditions'] = 'yb.id = Yarn.yarn_brand_id';
                $options['fields'] = array('Yarn.name');
                $options['conditions']['cont.material_id'] = $this->request->data['Yarn']['material_id'];
                $options['conditions']['Yarn.yarn_brand_id'] = $this->request->data['Yarn']['yarn_brand_id'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

c = Conversation.joins(:messages).random >> Conversation Load (8.1ms) SELECT `conversations`.* FROM `conversations` INNER JOIN `messages`
I am looking for a way to perform multiple joins from one source table
I'd like to use the .Join() method in LINQ to perform the following SQL:
I would like to know whether I could perform a full outer join between
i am newbie in rails and try to perform left join in mysql. there
When you perform a left join in TSQL (MSSQL SERVER) is there any guarantee
I am trying to get ActiveRecord to perform the following query: SELECT A.*, B.*,
I'm using this query to perform a full text search on a MySQL database:
I am new to linq and want to perform joins across three tables. The
I have one Linq to SQL query that simply joins three tables and then

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.