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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:56:29+00:00 2026-05-25T19:56:29+00:00

I’m extending a basic shopping cart system and need a way to show all

  • 0

I’m extending a basic shopping cart system and need a way to show all invoices in which a given product was purchased. I’m not sure a SELECT can be done this way, but I could a boost.

The problem is that invoice IDs correspond to shopping cart entries which identify the product IDs being purchased. I am querying for all purchases within a given category of products (p.categoryid).

SELECT i.id, i.name, i.totalprice, i.dateof
FROM invoices i
WHERE i.status > '1' AND i.id IN (
    SELECT c.invoice FROM maj_cart c, maj_products p WHERE c.pid = p.pid AND p.categoryid = '43'
)

Here is my database structure:

CREATE TABLE IF NOT EXISTS `maj_cart` (
`cid` int(10) NOT NULL auto_increment,
`pid` int(10) NOT NULL default '0',
`sessid` varchar(50) NOT NULL default '',
`dateof` int(10) NOT NULL default '0',
`price` decimal(10,2) NOT NULL,
`shipping` decimal(10,2) NOT NULL,
`discount` decimal(10,2) NOT NULL,
`quantity` int(10) NOT NULL default '0',
`total` decimal(10,2) NOT NULL,
`invoice` int(10) NOT NULL default '0',
`status` int(1) NOT NULL,
PRIMARY KEY  (`cid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;

CREATE TABLE IF NOT EXISTS `maj_invoices` (
`id` int(10) NOT NULL auto_increment,
`dateof` int(10) NOT NULL default '0',
`userid` int(10) NOT NULL default '0',
`sessid` varchar(50) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`company` varchar(150) NOT NULL,
`email` varchar(255) NOT NULL default '',
`address1` varchar(255) NOT NULL default '',
`address2` varchar(255) NOT NULL default '',
`city` varchar(255) NOT NULL default '',
`state` char(3) NOT NULL default '',
`zip` varchar(10) NOT NULL default '',
`phone` varchar(40) NOT NULL default '',
`phone2` varchar(40) NOT NULL,
`instructions` text NOT NULL,
`recipmssg` text NOT NULL,
`promo` int(10) NOT NULL,
`discount` decimal(10,2) NOT NULL,
`totalprice` decimal(10,2) NOT NULL default '0.00',
`filename` varchar(20) NOT NULL,
`status` int(1) NOT NULL default '0',
`shipped` int(1) NOT NULL default '0',
`errorno` int(1) NOT NULL default '0',
`notes` text,
`source` int(5) NOT NULL default '0',
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=1 ;

CREATE TABLE IF NOT EXISTS `maj_products` (
`pid` int(10) NOT NULL auto_increment,
`itemnum` varchar(30) NOT NULL default '',
`filename` varchar(100) default NULL,
`original` varchar(255) default NULL,
`itemname` varchar(255) NOT NULL default '',
`descrip` text,
`summary` varchar(100) NOT NULL default '',
`categoryid` int(11) NOT NULL default '0',
`userid` int(10) NOT NULL default '0',
`dateadded` int(12) NOT NULL default '0',
`displayorder` int(10) NOT NULL default '0',
`price` decimal(10,2) NOT NULL default '0.00',
`shipping` decimal(10,2) NOT NULL default '0.00',
`instock` int(10) NOT NULL default '0',
`discount` int(10) NOT NULL,
`meta_keywords` text NOT NULL,
`meta_descrip` text NOT NULL,
PRIMARY KEY  (`pid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=1 ;
  • 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-25T19:56:29+00:00Added an answer on May 25, 2026 at 7:56 pm

    The suggested method would be just a normal join:

    SELECT i.id, i.name, i.totalprice, i.dateof
    FROM invoices i
    INNER JOIN maj_cart c ON c.invoice = i.id
    INNER JOIN maj_products p ON c.pid = p.pid
    WHERE p.category_id = 43
    AND i.status > '1'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.