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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:30:07+00:00 2026-05-28T07:30:07+00:00

In our MySQL database, I have a third_party_accounts table and it has_many third_party_campaigns .

  • 0

In our MySQL database, I have a third_party_accounts table and it has_many third_party_campaigns. However, not all accounts will have campaigns. What I would like to do in DBIx::Class is select only those accounts which have one or more campaigns. The simplest was I’ve found is as follows:

my $third_party_account_rs = $schema->resultset('ThirdPartyAccount');
my $with_campaigns_rs      = $third_party_account_rs->search(
    { third_party_account_id => \'IS NOT NULL' },
    {
        join     => 'third_party_campaigns',
        group_by => 'me.id',                                                                                                                                 
    }
);

For the relevant database columns:

mysql> select id from third_party_accounts;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

mysql> select id, third_party_account_id from third_party_campaigns;
+----+------------------------+
| id | third_party_account_id |
+----+------------------------+
|  1 |                      1 |
|  2 |                      2 |
|  3 |                      1 |
+----+------------------------+
3 rows in set (0.00 sec)

This seems like such an obvious use case that I’m sure there’s a simple way to do this, but I can’t find it.

  • 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-05-28T07:30:07+00:00Added an answer on May 28, 2026 at 7:30 am
    my $with_campaigns_rs = 
        $schema->resultset('ThirdPartyCampaigns')
        ->search_related('third_party_account');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysqldump backup of my mysql database consisting of all of our
We have 50 tables in our mysql database. Queries are taking time as many
I have a mySQL database that tracks our projects and drives our website's display
We have a MySQL database that is set up on one of our servers.
We are moving our mysql database to strict_all_tables from non-strict mode and would like
I have a MySQL database with a PHP front-end. I would like to implement
We have a nullable (type long) column (named referral) in our MySQL database. We
I am trying to write a script to patch our mysql database. Something like
We (apparently) had poorly executed of our Solaris MySQL database engine last night. At
I'm working on a SaaS project and mysql is our main database. Our applications

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.