I have a single table that stores data weirdly - I cannot change the structure of the table or the database itself, I have to work with this data:
I need to turn this data:
NID        SID        CID        DATA
1000       10         1          This
1000       10         2          is
1000       10         3          data
1000       11         1          This
1000       11         2          is
1000       11         3          lore
1000       12         1          This
1000       12         2          is
1000       12         3          picard
Into this:
This      is      data
This      is      lore
This      is      picard
But I can't seem to figure out just how to join this stuff together, it's not clicking in my brain.
Can I have multiple SELECT statements to bring this together? Something like
SELECT data FROM submitted WHERE nid='1000' AND cid='1' AS col1
SELECT data FROM submitted WHERE nid='1000' AND cid='2' AS col2
SELECT data FROM submitted WHERE nid='1000' AND cid='3' AS col3
And then my PHP code could be as simple as
print ("<tr>
<td>$row[col1]</td>
<td>$row[col2]</td>
<td>$row[col3]</td>
</tr>");
I don't think MySQL accepts "AS" after a "WHERE". It's been years since I touched MySQL, so I'm super rusty, thanks for any help.
 
    