I have 2 mysql tables that are joined, in the database, by the descriptionId field.
dataTable.dataId
dataTable.descriptionId
dataTable.userId
dataTable.value
descriptionLookupTable.descriptionId
descriptionLookupTable.descriptionName
In PHP, I am trying to update the field: dataTable.value, when dataTable.descriptionID = Gender
and the dataTable.userId = $_SESSION['userId']
.
For example in the descriptionLookupTable: descriptionLookupTable.descriptionId = 1
and descriptionLookupTable.descriptionName = Gender
. And in the dataTable: dataTable.descriptionID = 1
.
I understand the part that deals with the userID by using:
"WHERE dataTable.userId = '" . $_SESSION['userId'] . "'";
But I can't figure out how to use INNER JOIN.
The following query does not work.
$query = "UPDATE dataTable
INNER JOIN descriptionLookupTable
ON dataTable.descriptionId = descriptionLookupTable.descriptionId
AND descriptionLookupTable.descriptionName = Gender
SET Gender = '$gender' WHERE dataTable.user_id = '" . $_SESSION['user_id'] . "'";
The error message is: Unknown column 'Gender' in 'field list'
.