I have two tables.
task table
task_name = primary key
+----+-----------+
| id | task_name |
+----+-----------+
| 1 | Task 1 |
| 2 | Task 2 |
| 3 | Task 3 |
+----+-----------+
manager table
task_id = foreign key of task_name in task table
+----+------------+---------+
| id | set_status | task_id |
+----+------------+---------+
I need to show the manager table, but instead of task_id (showing the IDs of the task_name ) I need to show the actual task name, in place of task_id.
And also show set_status pending by defult when initialy task created by user.
required output
+----+------------+---------+
| id | set_status | task_id |
+----+------------+---------+
| 1 | pending | Task 1 |
| 2 | pending | Task 2 |
| 3 | pending | Task 3 |
+----+------------+---------+
I have tried a few queries:
SELECT t1.task_name, t2.task_id
FROM task t1
INNER JOIN manager t2
ON t1.id = t2.task_id
But I got
+-----------+---------+
| task_name | task_id |
+-----------+---------+
| Task1 | 1 |
+-----------+---------+
question from:
https://stackoverflow.com/questions/66048603/how-to-get-column-name-from-1-table-to-another-table 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…