Ok so what does mysql return when the select query doesnt exist. So say I query the database: SELECT username FROM user WHERE username='test' AND password='test'

Ok so say test doesnt exist what will the database return because i code in java and have made a method that should return true or false. True if the the thing exists in the query and false if it doesnt. But for some reason it always returns true. It turns out because mysql returns something each time.


Hi, I am not sure how you are validating what mysql returns. In php, when you query the table, for example,

//query the table with username and password 
$query = "select * from table where username='test' and password='test'";
//execute the query and save the resource in $result. 
$result = mysql_query($query);
//If the variable $result is true and if the query returns more than 0 rows, (meaning, there is a record!) then display convenient message.
if(mysql_num_rows($result) > 0) {
 echo "Username and password exists!";
} else {
//else, no records exist
 echo "No records found.";

In php however, this will return false if a record doesn't exist in the table. If it has a record, then it will return all the columns of that record as a resource.
I am not sure about Java, but I think mysql will return an empty result set if no records are found.