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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:31:33+00:00 2026-06-02T08:31:33+00:00

I have categories table: cat_id cat_name Than categories – posts relationship table cat_rel :

  • 0

I have categories table:

cat_id
cat_name

Than categories – posts relationship table cat_rel:

cat_rel_id
cat_id
post_id

And posts table:

post_id
post_title
post_content

Now I have data in all these tables, I need to pull out categories without to repeat those that have more than 1 post. I get somehow category repeated if it has more than 1 post, eg. categories like:

php, python, c++, java, ruby

if I have 2 posts under PHP, I will get:

php
python
php
java

and this is the query I run:

SELECT categories.cat_name, cat_rel.post_id 
FROM categories 
LEFT JOIN cat_rel ON cat_rel.cat_ID = categories.cat_ID

Any help about making those categories not to repeat, would be 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-06-02T08:31:34+00:00Added an answer on June 2, 2026 at 8:31 am

    Use DISTINCT

    Have a look here:
    SQL SELECT DISTINCT Statement

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

Sidebar

Related Questions

I have two table posts & categories post_id | post_title | post_content | post_cat
I have the following table: categories: cat_id | cat_cat | cat_name 1 | 0
I have table with product_category and its has more than 20 categories and I
I have a Categories table in which each category has a ParentId that can
I have a categories table, which one of the fields serves as the foreign
I have a categories table view controller. In my app, categories can have subcategories.
I have a table named categories, which contains ID(long), Name(varchar(50)), parentID(long), and shownByDefault(boolean) columns.
I have a table of categories. Each category can either be a root level
I have a self referencing table named categories that has a parentcategoryid column that
If I have a table of categories with a featured row that is default

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.