I have two tables: game and tasks
Game looks like this:
| step | manualTaskCounter | autoTaskCounter | (and other)
----------------------------------------------------------
| 1 | 3 | 1 | ...
----------------------------------------------------------
Tasks looks like this:
| id | taskType | taskContent |
-------------------------------
| 1 | M | abc |
| 2 | M | cde |
| 3 | A | efg |
| 4 | M | jpq |
Since tasks holds both, manual (with M taskType) and automatic (A) tasks I want to select. My API holds two variables: mTaskCounter and aTaskCounter. for example if mTaskCounter = 3 I want to select 3rd row of type manualTask from tasks. Since it is in fact row with id = 4 I can not use id in WHERE clause.
What I already achieved is:
SELECT
id,
taskType,
taskContent,
(@row:=@row + 1) as rowNumber,
g.manualTaskCounter as mTaskCounter
FROM
tasks t,
(SELECT @ROW:=0) AS r,
(SELECT manualTaskCounter FROM game) AS g
WHERE
g.manualTaskCounter = rowNumber
This says "unknown column 'rowNumber' in where clause
I also tried to use LEFT JOIN:
SELECT
id,
taskType,
taskContent,
(@row:=@row + 1) as rowNumber,
g.manualTaskCounter as mTaskCounter
FROM
tasks t,
(SELECT @ROW:=0) AS r
LEFT JOIN
`game` g ON g.manualTaskCounter = rowNumber
Same result. It's been a while since I used mysql everyday and dont know how to fix it. I also think to make two tables - manualTasks and autoTasks instead of tasks so it qould solve the problem by common select taskContent from autoTasks a LEFT JOIN game ON a.id = game.autoTaskCounter