Reply
SQL multiple orders' information
Old 07-21-2009, 05:07 PM SQL multiple orders' information
Novice Talker

Posts: 11
Name: Eric
Trades: 0
So say I have a database called "orders" with a couple of columns:

name, email, ccinfo, product1key, product2key, product3key, etc.

Each row is a separate order. Product1key, 2, and 3 are license keys.

Let's say John Doe first buys product1, then buys product2 in a separate transaction. He uses the same email address for both of these.

I want to write a function that will retrieve every single license key that email address has ever bought. Right now it only currently retrieves the first one, and so would only retrieve product1 in John's case. How would I make it so it retrieves every key he's bought, even if he got them on separate orders?

Thanks much.
yangez is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 07-24-2009, 02:35 PM Re: SQL multiple orders' information
Lashtal's Avatar
PHP Learner

Posts: 492
Name: Lashtal
Trades: 0
try grouping each product key to the same table, call it something like "Product Keys"

and give each distinct key (Product1key, 2, 3) it's own row in said table.
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-24-2009, 02:46 PM Re: SQL multiple orders' information
chrishirst's Avatar
Super Moderator

Posts: 22,226
Location: Blackpool. UK
Trades: 0
Code:
SELECT product1key,product2key,product3key FROM orders WHERE name = 'value_for_name';
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-28-2009, 03:18 PM Re: SQL multiple orders' information
Novice Talker

Posts: 11
Name: Eric
Trades: 0
Ah, very nice. Thank you!
yangez is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to SQL multiple orders' information
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11715 seconds with 13 queries