I am a PHP and MySQL beginner. I am currently doing a top up system that include package service. A customer can purchase available packages which define by admin, table are separate into three: customer, package, customer_package. Customer can slowly spend the package money too so amount are turn into record:
CUSTOMER(ID ......)
PACKAGE(ID , OFFER_RATE , PRICE )
CUSTOMER_PACKAGE( ID, AMOUNT , CUSTOMER_ID, PACKAGE_ID )
I have no problem displaying all choices to the customer, but my problem is if a customer already purchased one of them, how do I only show the rest of the available choices to customer?
My overall idea about the query
SELECT * FROM PACKAGE WHERE ID <>(already in customer_package)
Try a subquery:
Or a JOIN
Replace 55 with the proper customer id (variable).