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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:25:38+00:00 2026-05-26T06:25:38+00:00

Given two tables: (incoming greatly reduced/simplified example that exhibits the key problem) app_data represents

  • 0

Given two tables: (incoming greatly reduced/simplified example that exhibits the key problem)

app_data represents applications that can be subscribed to

id   app_name
 1   apple
 2   berry
 3   cherry

app_sub maps email addresses to applications

id   email
 1   alex
 2   bob
 2   coby

I’d like to generate a table from a single-user point-of-view showing which applications the current user is subscribed to and not.

For example, from Alex’s perspective I’d like to get:

desired_table

id    app_name    is_subscribed
 1    apple       true
 2    berry       false
 3    cherry      false

The following pure SQL query seems to be fine:

select id, app_name, email
  from app_data left join ( select *
                              from app_sub
                             where email='alex'
                          ) as subquery
                          on app_name.id=app_data.id;

However I’m having great difficulty getting that to work in dbix-class.

Alternatively, I tried to eliminate the subquery like so:

$app_data_resultset->search( { -or => [ { email => 'alex' },
                                        { email => undef },
                                      ],
                             },
                             { select => [ qw{ me.id
                                               me.app_name
                                               app_sub.email
                                             },
                                         ],
                               as => [ qw{ id
                                           app_name
                                           email
                                         },
                                     ],
                               join => 'app_sub',
                           );

However, this (now expectedly) results in the following (after treating both 0 and null as false):

bad_table

id    app_name    is_subscribed
 1    apple       true
 3    cherry      false

Since ‘bob’ and ‘coby’ are subscribed to id 2, the where clause completely eliminates the second id.

Any help would be greatly appreciated!

  • 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-26T06:25:38+00:00Added an answer on May 26, 2026 at 6:25 am

    Vincent, I am trying to join to a subquery now myself. I cannot find anyone succeeding so far.

    An alternative is to just do it in plain SQL with $c->model(‘blah’)->storage->dbh->prepare(“query”) OR the ‘Arbitrary SQL through a custom ResultSource’ section of the DBIx Class Cookbook, which also seems like a reasonable way.

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

Sidebar

Related Questions

Problem Given the following two tables, I'd like to select all Ids for Posts
So I have two tables in this simplified example: People and Houses. People can
Given that I have two tables Customer (id int, username varchar) Order (customer_id int,
Given two tables, one for workers and one for tasks completed by workers, CREATE
given the two tables and values: Tables People- Columns: [ID]PK Name Field - Columns:
Given a database with two tables X and Y , I have a query
I have 10 tables in my database(MySQL). two of them is given below tbl_state
Given two tables of equal structure, but one with 100M rows and another with
I have two tables that look a little like this AGR_TERR_DEF_TERRS ID DEF_ID TERRITORY_ID
I have two tables CREATE TABLE table1 (id int primary key auto_increment,....); CREATE TABLE

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.