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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:23:10+00:00 2026-05-16T03:23:10+00:00

I’m trying to get all products from the database with a single query. I

  • 0

I’m trying to get all products from the database with a single query. I get stuck at the price part:

VirtueMart has a table called #__vm_product and another one called #__vm_product_price.

If a product has a parent product, it means that product inherits everything from the parent unless it’s set different in the child.

The tables look like this:

/* #__vm_product PARTIAL */
int - product_id
int - product_parent_id
varchar - product_name

/* #__vm_product_price PARTIAL */
int - product_id
decimal - product_price
int - mdate

I made the next query which gets all products with their price:

SELECT
p.product_id AS id,
product_name AS name,
product_price AS price,
p.product_parent_id AS parent,
MAX(pp.mdate) AS last_updated

FROM jos_vm_product p
LEFT JOIN jos_vm_product_price pp ON p.product_id = pp.product_id

GROUP BY p.product_id
ORDER BY p.product_id

The problem with this query is that it doesn’t check if their is a price specified. So if it’s a child product and it has no price, it should show the price of it’s parent.

Could someone help me out with this?

Note: If anyone knows an easier way to get all products (with price) from the VirtueMart database, please don’t mind to tell me 🙂

EDIT: Price is never null. If child is supposed to inherit from it’s parent it just doesn’t have a price row in jos_vm_product_price

  • 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-16T03:23:10+00:00Added an answer on May 16, 2026 at 3:23 am

    Updated:

    select
        p.product_id AS id, 
        p.product_name AS name, 
        coalesce(pp.product_price, pp2.product_price) AS price, 
        p.product_parent_id AS parent, 
        coalesce(pp.mdate, pp2.mdate) AS last_updated 
    from jos_vm_product p 
    left outer join jos_vm_product p2 on p.product_parent_id = p2.product_id
    left outer join (
        select product_id, max(mdate) as maxmdate
        from jos_vm_product_price
        group by product_id
    ) ppm on p.product_id = ppm.product_id
    left outer join jos_vm_product_price pp on ppm.product_id = pp.product_id and ppm.maxmdate = pp.mdate 
    left outer join (
        select product_id, max(mdate) as maxmdate
        from jos_vm_product_price
        group by product_id
    ) ppm2 on p2.product_id = ppm2.product_id
    left outer join jos_vm_product_price pp2 on ppm2.product_id = pp2.product_id and ppm2.maxmdate = pp2.mdate 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.