[MYSQL]Query returns false!

Started by !, Apr 03, 2017, 11:51 AM

Previous topic - Next topic

!

Created Table using
MYSQLTest <- mysql_connect("blabla", "blabla", "blabla", "blabla");
mysql_query( MYSQLTest, "CREATE TABLE IF NOT EXISTS TTP( Name TEXT, TTP NUMERIC, Onine_Time TEXT )" );
Now by simply using this query
local myqueryttp = mysql_query( MYSQLTest,"SELECT Name FROM TTP WHERE Name='"+player.Name+"'");
The query returns false & connection and everything else is fine. :(

Discord: zeus#5155

Shadow

Not trying to be rude but, why would you query for a name if you know the name? lol
QuotePS:is trash is ur home language??

vito

Quote from: Shadow on Apr 03, 2017, 12:30 PMNot trying to be rude but, why would you query for a name if you know the name? lol
To check if name exists in "TTP" maybe.

!

Quote from: vito on Apr 03, 2017, 12:57 PM
Quote from: Shadow on Apr 03, 2017, 12:30 PMNot trying to be rude but, why would you query for a name if you know the name? lol
To check if name exists in "TTP" maybe.
Yup
its just an example of simple query which returns false everytime.
Any idea how to fix this.

Discord: zeus#5155

Thijn

What does mysql_error return?

.

To that query, I would suggest limiting the results to 1 in order to prevent searching the remaining rows if the condition was met. Thus avoiding the removal of hot data from the cache to make room for something that isn't even relevant.
.

vito

Maybe there should be used COUNT() because one don't need a data from table, just checking.

.

COUNT() is kinda irrelevant since you only select a single row. This is equal to simply selecting the row ID instead of the name. Except the latter might be simpler and or faster.
.

vito

Dunno, need to make a benchmark w/o cache to test what is faster.

!

Quote from: Thijn on Apr 03, 2017, 04:29 PMWhat does mysql_error return?
Not tried ill check..

Quote from: happymint on Apr 03, 2017, 05:00 PMTo that query, I would suggest limiting the results to 1 in order to prevent searching the remaining rows if the condition was met. Thus avoiding the removal of hot data from the cache to make room for something that isn't even relevant.
I cant, actually i am using queries for webstats.
The given example was just to show that simple query returns false.

Quote from: vito on Apr 03, 2017, 05:38 PMDunno, need to make a benchmark w/o cache to test what is faster.
Ill try it tomorrow.

Discord: zeus#5155

Cool

@zeus Give proper permissions to your db or check table is exists or not because i run the same query only change the db name and tabble name its not giving any error