•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 362,344 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,781 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 936 | Replies: 2
![]() |
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Guys,
without saying anything much, I have such data at hand (rows from a database table):
Following someone's wise words, I would love to have this transformed to :
DO NOT assume that there will be ONLY a single cell/column with multiple values.
The following might also arise :
This has to be transformed to :
C++ code or suggestions would be great.. although I am interested in knowing more about ;
1. Working implementations/snippets
2. Alternative but automated or programmatic approaches to get equivalent output.
3. Links to other resources where I might get more answers to this question.. for example any good database experts forums you guys might know/heard about.. visit etc...
I am really looking forward to some help on this because I thought up a recursive solution to this problem but I got stuck when I found out that I would have to know and predefine the table schema and model an object/class/structure on it.. that would make my program not applicable for any table, but rather I would have to redefine and recompile the classes for the table schema for every table.
I am sure there are easier ways out.
without saying anything much, I have such data at hand (rows from a database table):
111 | xyz | a, b, c
Following someone's wise words, I would love to have this transformed to :
111 | xyz | a 111 | xyz | b 111 | xyz | c
DO NOT assume that there will be ONLY a single cell/column with multiple values.
The following might also arise :
111 | xyz, def | a, b, c
This has to be transformed to :
111 | xyz | a 111 | xyz | b 111 | xyz | c 111 | def | a 111 | def | b 111 | def | c
C++ code or suggestions would be great.. although I am interested in knowing more about ;
1. Working implementations/snippets
2. Alternative but automated or programmatic approaches to get equivalent output.
3. Links to other resources where I might get more answers to this question.. for example any good database experts forums you guys might know/heard about.. visit etc...
I am really looking forward to some help on this because I thought up a recursive solution to this problem but I got stuck when I found out that I would have to know and predefine the table schema and model an object/class/structure on it.. that would make my program not applicable for any table, but rather I would have to redefine and recompile the classes for the table schema for every table.
I am sure there are easier ways out.
•
•
Join Date: Aug 2005
Location: Trailer trash caravan park, just down the road from loserville
Posts: 4,549
Reputation:
Rep Power: 15
Solved Threads: 284
Yeah it seems like you need some sort of generic way to set up an arbitary number of nested for loops. Perhaps recursion of some sort.
I think hard coding it would be the simplest solution.
//111 | xyz, def | a, b, c
#include <iostream>
#include <string>
using namespace std;
int main()
{
string array1[] = "111";
string array2[] = {"xyz", "def"};
string array3[] = {"a", "b", "c"};
for ( int i = 0; i < 1; i++ )
{
for ( int j = 0; j < 2; j++ )
{
for ( int k = 0; k < 3; k++ )
{
cout << array1[i] << " " << array2[j] << " " << array3[k] << endl;
}
}
}
cin.get();
}I think hard coding it would be the simplest solution.
Last edited by iamthwee : Nov 16th, 2007 at 7:51 am.
Member of: F-ugly code club
Join today don't delay!
Join today don't delay!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Database Design Marketplace
- My "favorites" vanished, how do i retrieve them (Web Browsers)
- From "Word" to "Access" automatically (MS Access and FileMaker Pro)
- Change "<table..." definition with preg_replace_callback (PHP)
- google "keyword" question (Search Engine Optimization)
- i = system ("cd c:\text"); :( (C)
- W32.Blaster.Worm - RPC vulnerability causes reboots in Windows NT, 2K, and XP. (Windows NT / 2000 / XP / 2003)
Other Threads in the Database Design Forum
- Previous Thread: How do I divide the sum of 2 columns in sql 2000 server
- Next Thread: Database Maintenance and Upgrade Effort



Linear Mode