How do I pass the COUNT attribute in my sql string, since "COUNT" is a reserved php word?

Asked

Viewed 91 times

0

Follows the string of select:

$resultado = mysqli_query($conn, "SELECT COUNT(*) FROM conta WHERE username:usuario AND userpassword:senha";
  • Missing close a parenthesis at the end of your code.

  • 2

    If the count will be inside a string makes no difference if it is reserved word or not.

1 answer

0

The count(*) is inside the string, so no problem, to get its value and be more readable too, I suggest assigning an alias to it ex: select count(*) as total from ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.