Please tag your database for more info.
This is one way for Oracle where Ihave used a concatenate sign which is ||
to concatenate(put two strings together in one) and between them I have also concatenated a comma ,
. You can also see that I have used double quotes for the column named desc
. I did it because it is not a good practice to call your columns with keywords and word desc
is used for example when you order by some column(at the end of the query) you can order by that column ascending then you use asc
or descending when you can use desc
. Also in both examples I used keyword as
to give a name to this concatenated column.
SELECT class_id, cpab.ability_id || ',' ||
ab.ability_id || ',' ||
ab.name || ',' ||
class_id || ',' ||
cpab.name || ',' ||
hit_die || ',' ||
"desc" || ',' ||
isPlayable as values
FROM rpg.class_primary_abilities AS cpab
INNER JOIN rpg.abilities AS ab ON cpab.ability_id = ab.ability_id
INNER JOIN rpg.classes AS cl ON cpab.class_id = cl.class_id;
This is another for MYSQL where I have used concat
to concatenate column values and I have used different single quotes for desc
column.:
SELECT class_id, concat(cpab.ability_id, ',' ,
ab.ability_id, ',' ,
ab.name, ',' ,
class_id, ',' ,
cpab.name, ',' ,
hit_die, ',' ,
`desc`, ',' ,
isPlayable) as values
FROM rpg.class_primary_abilities AS cpab
INNER JOIN rpg.abilities AS ab ON cpab.ability_id = ab.ability_id
INNER JOIN rpg.classes AS cl ON cpab.class_id = cl.class_id;
In both examples you have columns with same name from different tables and theer you will have to use aliases when calling them in your select clause like I have did in my example: cpab.ability_id
and ab.ability_id
but please note that I do not know if they are from cpab and ab tables.