I am trying to fetch a single value (the id) from a mysql database in PHP. I know this can be done in the following way:
$q = "SELECT * FROM users WHERE email ='" . $email . "'";
$result = $conn->query($q);
$row = $result->fetch_assoc();
echo $row["id"];
However, I would think that I could speed up the query by instead of querying the entire row, I would only make a query for the id, which I would do like so:
$q = "SELECT 'id' FROM users WHERE email ='" . $email . "'";
$result = $conn->query($q);
$row = $result->fetch_assoc();
echo $row["id"];
But for some reason, this returns the string "id", instead of the actual value. I have looked at a couple other similar questions, and the answers that I've tried from those gave the exact same result.