| | |
What does mysql return when the selection doesnt exist?
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
Thanks
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.
Thanks
There are 10 types of people in this world, those that understand binary and those that don't :).
-1
#2 27 Days Ago
Hi, I am not sure how you are validating what mysql returns. In php, when you query the table, for example,
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.
MySQL Syntax (Toggle Plain Text)
//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."; }
I am not sure about Java, but I think mysql will return an empty result set if no records are found.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- [req] how to check whether given oracle table exist or not + C# (C#)
- MySQL return month and date from NOW() (MySQL)
- interesting code......Help (C++)
- php queries to mysql do not return anything. (MySQL)
- Help in C (C++)
- storing details as html doc using php (PHP)
- generating txt using php (PHP)
- Terrible Error while using MySQL resources (PHP)
- include() and require() (PHP)
- writing a simple cat program (C)
Other Threads in the MySQL Forum
- Previous Thread: SQL statement for easier db a search
- Next Thread: Remove last chars
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groupware hiring hyperic images innerjoins insert ip joebrockmeier join keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






