I am very inexperienced with SQL. I have a table that looks like this:
Columns: A B C D E
foo bar 1 2 3
foo bar 4 5 6
foo bar 7 8 9
xyz abc 3 2 1
xyz abc 6 5 4
xyz abc 9 8 7
Now I want to be able to form a string like so:
"foo bar: 1 2 3 4 5 6 7 8 9"
"xyz abc: 3 2 1 6 5 4 9 8 7"
If it matters I also have a list of the A and B columns I can use naively by going:
Rs1 = SELECT * FROM PARENT_TABLE:
for a, b in RS1
String = a + b
Rs2 = SELECT C, D, E FROM CHILD_TABLE WHERE A='a' AND B='b'
for every row in Rs:
String += C D E
print String
Is there anyway to do this WITHOUT having to iterate through the parent table and then on each row form a statement and thus iterate on that one as well. Am I missing an obvious solution?
You want to look up aggregate functions: