Hi,
I have these 3 tables in my DB.
1. tbl.Member
a. name
b. email
c. username(pri key) ...and other stuff
2. tbl.Product
a. id (pri key)
b. product name
c. category .... and other stuff
d. company(from table maker)
3. tbl.Maker
a. id (pri key)
b. company
c. email and other stuff
When the members are browing products they choose and purchase most of
the products(atleas t they apply). These orders will be stored in the
4th table.
4. orders
a. id
b. product name
c. maker
d. username (from tbl.members)... .and other stuff.
The question is when a member with username jaunty is browsing the
products I want to show him an indication that he has already purchased
item no 5,9,15 etc.
assuming that I use the following query on the browse product page..
$query = select * from products;
how should I modify $query so that I can also indicate that jaunty has
purchased some of them.
I am very sure this should be a small trick I just want to make sure my
DB structure and queries are proper.
Please help me
Thanks 1 1459
SELECT
ProductName
,(SELECT CASE
WHEN ProductName IN
(SELECT
ProductName
FROM
ORDERS
WHERE
Name = 'Jaunty'
)
Then 'Yes'
Else 'No'
END
) AS 'Order History'
FROM
PRODUCT
A few suggestions:
- with your design a product can belong to only one category. You might want
to create another table called CATEGORIES and
an intesection table called PRODUCT_CATEGOR IES to handle a m:m
- don't use "tbl" as a prefix for table names
- it is typical to break out your ORDER table into two table 1)ORDERS
2)ORDER_DETAILS .
<sm***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com... Hi, I have these 3 tables in my DB.
1. tbl.Member
a. name b. email c. username(pri key) ...and other stuff
2. tbl.Product
a. id (pri key) b. product name c. category .... and other stuff d. company(from table maker)
3. tbl.Maker
a. id (pri key) b. company c. email and other stuff
When the members are browing products they choose and purchase most of the products(atleas t they apply). These orders will be stored in the 4th table.
4. orders
a. id b. product name c. maker d. username (from tbl.members)... .and other stuff.
The question is when a member with username jaunty is browsing the products I want to show him an indication that he has already purchased item no 5,9,15 etc.
assuming that I use the following query on the browse product page..
$query = select * from products;
how should I modify $query so that I can also indicate that jaunty has purchased some of them.
I am very sure this should be a small trick I just want to make sure my DB structure and queries are proper.
Please help me Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary form
for a number of platforms from our download pages at
http://www.mysql.com/downloads/ and mirror sites.
|
by: Philip Stoev |
last post by:
Hi all,
Please tell me if any of this makes sense. Any pointers to relevant
projects/articles will be much appreciated.
Philip Stoev
http://www.stoev.org/pivot/manifest.htm
===================================
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer uses his own php shopping cart to receive customer
orders.
The configuration was done via cPanel with no external modifications -
which produced no protests when built, ran and connected with no
|
by: Good Man |
last post by:
Hi there
I've noticed some very weird things happening with my current MySQL setup
on my XP Laptop, a development machine.
For a while, I have been trying to get the MySQL cache to work. Despite
entering the required lines to "my.ini" (the new my.cnf) through notepad
AND MySQL Administrator, the cache does not work.
So, today I took a peek at the 'Health' tab in MySQL Administrator.
| |
by: Juan Antonio Villa |
last post by:
Hello, I'm having a problem replicating a simple database using the binary
log replication, here is the problem:
When the master sends an update to the slave, an example update reads as
follows:
UPDATE MainInfo SET dAddress='38 Holland Blvd', dCity='miami',
dState='FL', dZip='33000', dCountry='USA', dPhone='999987565',
dNum='AC15857', dName='Michael A Scott' WHERE did=22'
|
by: Ike |
last post by:
Recently, I began using a different MySQL verver (i.e. different machine as
well as different version#, going from 4.12a to 4.1.9 max).
The following query used to work:
select firstname, lastname, from associates where username like 'nancianne'
but now fails with:
"You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'from associates
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get through this without much trouble. Programming knowledge is not required.
Index
What is SQL?
Why MySQL?
Installing MySQL.
Using the MySQL command line interface
|
by: Atli |
last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t.
In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files.
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |