I have two table that I need to combine in a specific way. I need the information in one table displayed once but I need the information in the next table to return every matching data it has. here is my example
user
| id | name |
-------------
| 1 | mike |
| 2 | john |
| 3 | bill |
-------------
class
-----------------
| uid | subject |
-----------------
| 1 | math |
| 1 | English |
| 2 | math |
| 3 | math |
| 3 | English |
-----------------
expected results
--------------------
|name | mike |
---------------------
|subject| math |
| | English |
---------------------
or
--------------------
|name | subject |
---------------------
|mike | math |
| | English |
---------------------
this is my current query
SELECT user.name, class.subject
FROM user
join class on class.uid = user.id
WHERE (user.name like '%mike%')
returns
--------------------
|name | subject |
---------------------
|mike | math |
|mike | English |
---------------------
but I want to remove all name duplicates. can anyone help with this query
nameand do the grouping in your application code.GROUP_CONCATfunction will assemble a comma-separated string of results with a common group. I think it's what you're looking for. (granted you're not really looking for a common result).