I want to return field name from a database table where id = 4. Which query is easier for MYSQL to process.
SELECT name, id FROM table WHERE id = 4
or
SELECT name FROM table WHERE id = 4
I suppose I’m asking if it’s good practice to put the field from the WHERE statement in SELECT as well even if I won’t return it in php.
would also have the id in the result from mysql and it would make very little difference to the data as it is only a numeral however if you were to do this where you were selecting something else such as
SELECT name, id FROM table WHERE name = "ron"would definitely a bad practice as more data is being transferred from the database server as you already know the name “ron” and since it is not unique it could have more than one rows.compared to