View Single Post
Old 01-29-2013, 04:54 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,178
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
The problem: Unless you want to return the SAME NUMBER of courses for each user, you can't do this in SQL.

That is you could *NOT* get back:
[1][jdoe][John][Doe][01-29-2012]
[2][adam][Adam][And][12-31-2012][2-29-2012][3-31-2012]
because you can not have a different number of columns per row.

You *could* do this with a combination of SQL and PHP/JSP/ASP code.

Or you would get back a *list* of dates (say comma delimited) as a single column:
[1][jdoe][John][Doe][01-29-2012]
[2][adam][Adam][And][12-31-2012,2-29-2012,3-31-2012]

Though I don't understand how you will interpret that if you don't know what date goes with what course.

Now, in your example, you showed exactly *two* courses, 1 with "no result". If you want exactly two courses for each person, *that* we can do, although it's not trivial at all.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote