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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:22:32+00:00 2026-05-31T16:22:32+00:00

I am actually stuck in merging the result of this two queries: first query:

  • 0

I am actually stuck in merging the result of this two queries:

first query:

SELECT c.code, c.name, pc.sku, pc.cat_code, pp.title 
FROM `cat_parent`  cp, cat c, prod_cat pc, products pp 
WHERE c.code = cp.cat_code 
  AND cp.cat_code = pc.cat_code 
  AND pp.sku = pc.sku 
  AND cp.parent_code = 01110 
  AND hide =0

The result I get is:

enter image description here

Second query:

SELECT `sku` , `update_date` , `description` , count( * ) AS total_sold 
FROM `orderline` 
WHERE `update_date` >= ( DATE_ADD(CURDATE( ) , INTERVAL -14 DAY ) ) 
  AND `update_date` <= ( DATE_ADD(CURDATE( ) , INTERVAL -7 DAY ) ) 
GROUP BY left( sku, 7 ) 
ORDER BY total_sold DESC

The result:
enter image description here

The question I want to ask that how can I get the result by filtering the sku available in both tables.

Just bit confused on that part….any ideas will be appreciated.

This is only part of the data. there is heaps of data. Yes, I want to merge the both tables and want to find the common sku available in both tables.

My expected result will be sku, title, total sold.

Thanks, anyway I managed to get around to get the result.

My final query:

SELECT * FROM (

SELECT sku , update_date , description FROM orderline WHERE
update_date >= ‘2012-03-06’ AND update_date <= ‘2012-03-07’ )g
JOIN (

SELECT c.code, c.name, pc.sku, pc.cat_code FROM cat_parent cp, cat
c, prod_cat pc, products pp WHERE c.code = cp.cat_code AND cp.cat_code
= pc.cat_code AND pp.sku = pc.sku AND cp.parent_code =01110 AND hide =0 )p ON left( g.sku, 7 ) = left( p.sku, 7 )

  • 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-31T16:22:33+00:00Added an answer on May 31, 2026 at 4:22 pm

    Something like this –

    SELECT
        `c`.`code`, `c`.`name`, `pc`.`sku`, `pc`.`cat_code`, `pp.title`,
        `ol`.`sku`, `ol`.`update_date`, `ol`.`description`, COUNT(*) AS `total_sold`
    FROM `cat_parent` `cp`
    INNER JOIN `cat` `c`
        ON `c`.`code` = `cp`.`cat_code`
    INNER JOIN `prod_cat` `pc`
        ON `cp`.`cat_code` = `pc`.`cat_code`
    INNER JOIN `products` `pp`
        ON `pp`.`sku` = `pc`.`sku`
    INNER JOIN `orderline` `ol`
        ON LEFT(`pc`.`sku`, 7) = LEFT(`ol`.`sku`, 7)
    WHERE `cp`.`parent_code` = 01110
    AND `hide` = 0
    AND `ol`.`update_date` >= ( DATE_ADD(CURDATE( ) , INTERVAL -14 DAY ) )
    AND `ol`.`update_date` <= ( DATE_ADD(CURDATE( ) , INTERVAL -7 DAY ) )
    GROUP BY left( `ol`.`sku`, 7 )
    ORDER BY `total_sold` DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I am stuck in middle of some mysql code. Can anyone suggest a
I am actually stuck in 3-tier structure. I surfed the internet and found two
NOTE: This is actually a database of a forum. I am stuck in an
I am already stuck for a couple of days with this code, I want
I have been stuck with this issue now all morning. I actually saw this
I am a bit stuck with this. I want to determine two opacity int
I'm stuck with a strange bug in my code. Actually I modified legacy code
This is actually my very first question on Stackoverflow. I hope its not the
Ok, I'm a bit stuck on this one, can I actually do what I'm
I have been stuck with this for a while now, Actually I have 2

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.