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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:29:06+00:00 2026-05-22T14:29:06+00:00

The following query only work when I have a reference in the table wm_purchased_products.purchased_article_id

  • 0

The following query only work when I have a reference in the table wm_purchased_products.purchased_article_id but when this is empty mysql_num_rows return 0

The query is:

  SELECT (SUM(wm_products_quantities.new_quantity) - SUM(wm_purchased_products.purchased_article_total) ) AS stock_restante, 
         wm_products_wall.nombre, 
         wm_products_wall.detalles, 
         wm_products_wall.price, 
         wm_products_wall.image_full, 
         wm_products_wall.fecha, 
         wm_products_wall.article_hashid
    FROM wm_products_wall,
         wm_products_quantities, 
         wm_purchased_products 
   WHERE wm_products_wall.categoria = '$new_rquery_xp' 
     AND wm_products_wall.article_hashid = wm_products_quantities.hashid_ref 
     AND wm_products_wall.article_hashid = wm_purchased_products.purchased_article_id 
GROUP BY wm_products_wall.article_hashid 
ORDER BY stock_restante ASC

How to build this query to work when I have no record in the table wm_purchased_products.purchased_article_id

  • 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-22T14:29:07+00:00Added an answer on May 22, 2026 at 2:29 pm

    Your code FROM wm_products_wall, wm_products_quantities, wm_purchased_products means all three table are INNER JOIN with each other.(that is, each and every row in the first table is joined to each and every row in the second table and so on.)

    You can let wm_products_wall LEFT JOIN with wm_purchased_products, so do wm_purchased_products.

    SELECT 
    (SUM(wm_products_quantities.new_quantity) - SUM(wm_purchased_products.purchased_article_total) ) AS stock_restante, 
    wm_products_wall.nombre, wm_products_wall.detalles, wm_products_wall.price, 
    wm_products_wall.image_full, wm_products_wall.fecha, 
    wm_products_wall.article_hashid
    FROM wm_products_wall
    LEFT OUTER JOIN wm_products_quantities
      ON wm_products_wall.article_hashid = wm_products_quantities.hashid_ref 
    LEFT OUTER JOIN wm_purchased_products
      ON wm_products_wall.article_hashid = wm_purchased_products.purchased_article_id
    WHERE wm_products_wall.categoria = '$new_rquery_xp' 
    GROUP BY wm_products_wall.article_hashid 
    ORDER BY stock_restante ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: SELECT COLUMN1, COLUMN2, COUNT(*) FROM TABLE WHERE COLUMN3 IS
I have the following query: SELECT Base.ReportDate, Base.PropertyCode, Base.FirstName, Base.MiddleName, Base.LastName, Person.FirstName, Person.MiddleName, Person.LastName
I have a query the following query : select Opp.[ID], Opp.ContactID, Opp.RTSID, Opp.[ProjectName], CONVERT(varchar,
I have the following query where I would like to return two result sets.
I have the following query: SELECT services.name as Service, services.logo_name as Logo, packages.name as
I have a following query (simplified): SELECT Id FROM dbo.Entity WHERE 1 = ALL
I have the following query: SELECT wm_concat(DISTINCT NAME) as Methods FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS
I'm trying to get the following query to work in Hibernate: SELECT m FROM
Let's say I have the following query. SELECT ID, Email, ProductName, ProductModel FROM Products
I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM

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.