Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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
 
 
Register now for full access!
Old 07-24-2009, 02:35 PM Re: SQL multiple orders' information
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
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.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-24-2009, 02:46 PM Re: SQL multiple orders' information
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
SELECT product1key,product2key,product3key FROM orders WHERE name = 'value_for_name';
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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.25957 seconds with 12 queries