I'm trying to get unique Value from two tables but the problem is the data in 'd.feedback' is displaying all of the data in the column feedback from daily_report table.
This is the code that I use. So what do you think I should do? Distinct fullname
and feedback
? or is there another alternative?
SET @row := 0;
SELECT DISTINCT CONCAT(@row := @row + 1,' ',ui.firstname) as 'Regular Users', d.feedback
FROM daily_report d INNER JOIN userinfo ui ON d.id = ui.userid
Here is the First Table
| userid | firstname |
| -- | ----------|
| 1 | Christian |
| 2 | Levi |
| 3 | Brian |
Here is the Second Table
| id | feedback | userid |
| -- | ----------|--------|
| 1 | Thanks | 1 |
| 2 | Arigato | 1 |
| 3 | Sure | 2 |
| 4 | Thank you | 2 |
Desired output
Regular User | feedback |
---|---|
1 Christian | Thanks |
2 Christian | Arigato |
3 Levi | Sure |
4 Levi | Thank you |
Read more here: https://stackoverflow.com/questions/66333609/mysql-how-to-get-unique-values-from-two-tables-mysql
Content Attribution
This content was originally published by Janel Sangalan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.