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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:02:00+00:00 2026-06-12T21:02:00+00:00

I have 2 tables; articles and article_shares (how many times an article has been

  • 0

I have 2 tables; articles and article_shares (how many times an article has been shared)

I want to show all articles by a user (id 63) and how many times they have shared the article (this could be 0)

Articles:

article_id - user_id  - title - date

Article_shares

article_id

I’m trying the following but it only returning the one row where there are shares but I want to show all, even if the number of shares is 0 (there are 7 articles in this case)

SELECT *, DATE_FORMAT(a.date, '%d/%m/%y') as article_date, count(*) 
from articles a 
join article_shares ash on ash.article_id = a.article_id
where (a.user_id = '63') order by a.article_title asc
  • 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-12T21:02:01+00:00Added an answer on June 12, 2026 at 9:02 pm

    Change your join to a left join

    Something like

    SELECT *, DATE_FORMAT(a.date, '%d/%m/%y') as article_date, count(*)  
    from articles a  
    left join article_shares ash on ash.article_id = a.article_id 
    where (a.user_id = '63') order by a.article_title asc
    

    Have a look at this example

    SQL Fiddle DEMO

    Also maybe have a look at Introduction to JOINs – Basic of JOINs

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

Sidebar

Related Questions

I have 4 tables... users, friends, articles & article_shares (as in written) A user
So I have two tables, article and comments (which has one-to-many relationship (1 article
I have three tables: articles(id int) tags(id int, name varchar(255)) articles_tags(article_id, tag_id) I want
I have three mysql tables, first holds information about articles (Article ID, author ID,
I have tables, 1 called articles and another called links. I want to take
I have two database tables Articles Archive Each article can have multiple records in
I have 2 tables: Articles: ID INTEGER ... Article_versions: article INTEGER lang ENUM time
I have three tables: Article(idArticle,NameArt) Tag(idTag, NameTag) ArtiTag(idArticle,idTag) I want to have a result
Assuming that I have 2 tables articles id title 1 Article 1 2 Article
I have these tables: table_a user_id article_id created_at articles user_id created_at ... I need

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.