Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table1:
- id (uniqueidentifier, primarykey)
- title (varchar(50))
- Table2:
- id (uniqueidentifier, primarykey)
- table1id (uniqueidentifier, foreignkey to table1)
- category (varchar(50))
- select t1.*, t2.category as cat from table1 as t1
- left join table2 as t2 on t1.id = t2.table1id
- Table2 row 1:
- id = 1
- table1id = 1
- category = "abc"
- Table2 row 2:
- id = 2
- table1id = 1
- category = "def"
- select t1.id, t1.title, group_concat(t2.category) as cat from table1 as t1
- left join table2 as t2 on t1.id = t2.table1id
- group by t1.id, t1.title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement