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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:40:29+00:00 2026-06-12T01:40:29+00:00

I need to check if an entry is categorized (query A) OR if an

  • 0

I need to check if an entry is categorized (query A) OR if an entry has a relationship with certain data (query B). I’d like to do this with one query rather than two separate queries. For example:

[if query A OR query B ]
   <p>Show this content</p>
[/if]

I have the two select queries working correctly, but only independently of one another. They are:

Query A:

SELECT entry_id FROM exp_category_posts WHERE entry_id = '999' AND cat_id IN(SELECT cat_id FROM exp_categories WHERE group_id = '5') LIMIT 1

Query B:

SELECT entry_id FROM exp_matrix_data WHERE field_id = '19' AND col_id_7 <> '' AND entry_id = '999'

Again, I’d like to combine these two queries into a single query that checks if entry 999 is EITHER categorized in certain categories (query A) OR has a relationship with certain data (query B). What is the best way to do this?

If it helps, the queries are being run on an ExpressionEngine database.

Disclaimer: I know there are plenty of questions on SO on how to combine MySQL SELECT statements, but I am looking for help on this specific query, and didn’t find any questions similar enough to my own. My apologies in advance if I have inadvertently angered the duplicate question gods.

  • 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-12T01:40:30+00:00Added an answer on June 12, 2026 at 1:40 am

    As your entry comes from two different tables and, as I understand your request, it doesn’t have to exist in both of them, you would need a FULL OUTER JOIN to do it with OR, which is not supported in MySQL.

    However, you can use a UNION to get your desired result:

    SELECT entry_id FROM exp_category_posts WHERE entry_id = '999' AND cat_id IN(SELECT cat_id FROM exp_categories WHERE group_id = '5') LIMIT 1
    UNION DISTINCT
    SELECT entry_id FROM exp_matrix_data WHERE field_id = '19' AND col_id_7 <> '' AND entry_id = '999'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to check if my address has any words that matches word in
I need help to debug this program . // VirtualFN.cpp : Defines the entry
I am trying to check whether an entry exists (one or more) in our
In my iphone app. i need to check if there is a multisession entry,
I need to check whether the two textboxes textbox_price and textbox_quantity contain numeric values
I am writing a fairly simple journal entry program, and I need to check
I need to check for a condition on each page I visit on the
I need to check for duplicates before saving to the database in the create
I need to check some settings for all users on Windows clients in the
I need to check if a link (a-tag) is the only content (not just

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.