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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:00:45+00:00 2026-06-01T15:00:45+00:00

As part of my ecommerce application, I have this interesting problem, I’ve been trying

  • 0

As part of my ecommerce application, I have this interesting problem, I’ve been trying to resolve.

I have two things.

  • Category
  • Product

In relational database sense, a category can have more than one products, and a product can only belong to category.

Then, I have this ecommerce admin coupon page where I want to modify the coupon details that’s associated with a particular product and category.

On the modify page, I have the following fields

Coupon description – TextField type
Coupon Price – TextField type
Coupon Percentage – TextField type
Category Name – Dropdownfield type
Product Name – Dropdownfield type

I have the following sql query.

$sql = "SELECT cp_description, cp_discountprice, cp_discountpercent, pd_name, cat_name
        FROM tbl_coupon inner join (tbl_product, tbl_category) on 
        (tbl_product.pd_id = tbl_coupon.pd_id AND     tbl_category.cat_id=tbl_product.cat_id)
        WHERE cp_id = $cpId";

What’s really interesting about this problem is that I could not include pd_id and cat_id fields into the sql query so I can manipulate them in another sql code that will look up these fields to retrieve correct selected element in a dropdown field when prepopulated.

I cannot use pd_name or cat_name in select statement because these fields are not ‘unique’ so can cause problems.

Does anybody have any idea what’s the best way to approach this problem? I thought the distinct keyword may do the trick… But it doesn’t!

  • 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-01T15:00:47+00:00Added an answer on June 1, 2026 at 3:00 pm

    Can’t you use a query like this?

    SELECT 
        cp.cp_description, cp.cp_discountprice, cp.cp_discountpercent, 
        p.pd_id, p.pd_name, 
        cat.cat_id, cat.cat_name
    FROM tbl_coupon cp 
    INNER JOIN tbl_product p ON p.pd_id = cp.pd_id
    INNER JOIN tbl_category cat ON p.cat_id = cat.cat_id 
    WHERE cp_id = $cpId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ecommerce site which currently has product URLs like this: http://www.mydomain.com/nike-tshirt/Large http://www.mydomain.com/nike-tshirt/Medium
Part of a Lua application of mine is a search bar, and I'm trying
Part of my code I get the OuterHTML propery <LI onclick=TabClicked(this, 'SearchName', 'TabGroup1');>Name so
Part of my code goes like this: while(1){ my $winmm = new Win32::MediaPlayer; $winmm->load('1.mp3');
Part of my application depends on JavaMail, moving arranging messages etc. Is it possible
Im interested in providing part of magento ecommerce as a SAAS solution. However, it
I need to make an Print product feature on my ecommerce site and the
Part of our product is an IE plugin (BHO), which is running happily in
I'm adding multi-currency support to an e-commerce application. The way I approached the problem
In Django, settings are stored in a file, settings.py. This file is part of

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.