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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:50:05+00:00 2026-05-26T18:50:05+00:00

I am having trouble figuring our how I can get results only when products.published,

  • 0

I am having trouble figuring our how I can get results only when products.published, product_types.published, and product_cats.published = 1 but my query isn’t working. Please help:

SELECT 
  `products`.`title`,
  `products`.`menu_id`,
  `products`.`short_description`,
  `products`.`datasheet_icon`,
  `products`.`datasheet`,
  `products`.`ordering`,
  `products`.`product_type_id`,
  CASE WHEN CHAR_LENGTH(`products`.`alias`)
    THEN CONCAT_WS(':', `products`.`id`, `products`.`alias`) 
    ELSE `products`.`id` 
  END AS slug 
FROM 
  `products`, 
  `product_cats`,
  `product_types`
WHERE 
  `products`.published=1 AND
  `product_cats`.published=1 AND
  `product_types`.published=1 AND
  `products`.`product_cat_id`='42' AND
  `product_types`.`id` IN (1,40,48,49,50)
GROUP BY `products`.`id`
ORDER BY `product_types`.`ordering`, `products`.`ordering`
  • 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-26T18:50:06+00:00Added an answer on May 26, 2026 at 6:50 pm

    I want to assume tables product_cats and product_types have product ids in them as well. And I call them pid in this:

    SELECT 
        p.title,
        p.menu_id,
        p.short_description,
        p.datasheet_icon,
        p.datasheet,
        p.ordering,
        p.product_type_id,
        CASE 
            WHEN CHAR_LENGTH(p.alias)
            THEN CONCAT_WS(':', p.id, p.alias) 
            ELSE p.id 
        END AS slug 
    FROM products p
        JOIN product_cats pc ON pc.pid = p.id
        JOIN product_types pt ON pt.pid = p.id
    WHERE 
        p.published=1 AND
        pc.published=1 AND
        pt.published=1
    GROUP BY p.id
    ORDER BY pt.ordering,p.ordering
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble figuring out why I can only get the children of
We are looking at adopting Git for our SCM but having trouble figuring out
I'm having trouble figuring out how to get the testing framework set up and
I'm having trouble figuring out how to represent the following JPQL query: SELECT count(e)
I am having trouble figuring out how to get protobuf-net to serialize an object
My company is having trouble figuring out the best way to manage our builds,
I'm having trouble figuring out how to get my program to keep track of
I'm having trouble figuring out if/how I can an internal webserver setup for testing
I am having trouble figuring out how to get Facebook insights into from my
I'm having trouble figuring out how to get Powershell to call an indexer on

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.