I'm using a Sybase ASE database.
I have two tables that look like:
Table Shops:
---------------------
| ShopName | ShopID |
---------------------
| Sweetie | 1 |
| Candie | 2 |
| Sugarie | 3 |
---------------------
Table Sweets:
----------------------
| SweetName | ShopID |
----------------------
| lolly | 1 |
| redlolly | 1 |
| greenloly | 1 |
| taffy | 2 |
| redtaffy | 2 |
| bluetaffy | 2 |
| choco | 3 |
| mintchoco | 3 |
| milkchoco | 3 |
| gummybees | 3 |
----------------------
I want to write a query that would generate a result that looks like:
-----------------------------------------------------
| ShopName | Sweets |
-----------------------------------------------------
| Sweetie | lolly, redlolly, greenlolly |
| Candie | taffy, redtaffy, bluetaffy |
| Sugarie | choco, mintchoco, milkchoco, gummybees |
-----------------------------------------------------
How should I go about doing that? I need this for a Sybase ASE database. I tried the LIST() function, but I'm getting an error on that. I checked its documentation, and turns out, this function is not available in the ASE Edition.
This probably means that there will be some "dynamic sql" involved (I have very little idea what that means). Can anyone help?
I could want ShopId instead of ShopName in the results table... I don't know for sure yet. I guess that won't be much of a difference. Also, trailing commas in Sweets column of results is not an issue. All I want is a non-whitespace separator.
list()give? Not that I can help with Sybase problems, but someone else who can might recognize the error message. - FrustratedWithFormsDesignerLIST()function was not found, and rightly so: I'm using Sybase ASE edition, which does not have this function (its documentation says so). This will probably need some T-SQL mumbo jumbo I guess, but I have no idea how to do that.. - jrharshathLIST()only works forSybase IQand not forSybase ASE. - Satyendra