mysql - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql (
/showthread.php?tid=346627)
mysql -
BaubaS - 29.05.2012
Is there is any other way to check is field null apart this?
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '%[]'", []);
mysql_query(Query);
mysql_store_result();
new szResult[lenght];
mysql_fetch_field_row(szResult, "Something");
if (szResult[0] == EOS)
{
...
}
else
{
...
}
Using MySQL not so long, so there may be mistakes even in this example code.
Thank you in advance.
Re: mysql -
Vince - 29.05.2012
PHP код:
WHERE something IS NULL
Re: mysql -
BaubaS - 29.05.2012
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Name` = '%e' AND `Something` IS NULL", ....);
mysql_query(Query);
mysql_store_result();
if (mysql_num_rows()
{
// field 'Something' is null
}
else
{
// field 'Something' is not null
}
Am I correct? Too lazy now :S
Re: mysql -
Vince - 29.05.2012
Yes, that should work. You can always quickly test queries in phpMyAdmin.
Re: mysql -
BaubaS - 30.05.2012
Doesn't work. I created two field in MySQL table: one with valid email, and one with null email field. Query returns that both accounts hasnt got null email field.
pawn Код:
mysql_query("SELECT `Email` FROM `zaidejai` WHERE `Vardas` = 'test1' AND `Email` IS NULL");
mysql_store_result();
if (mysql_num_rows()) print("test1: null");
else print("test1: not null");
mysql_query("SELECT `Email` FROM `zaidejai` WHERE `Vardas` = 'test2' AND `Email` IS NULL");
mysql_store_result();
if (mysql_num_rows()) print("test2: null");
else print("test2: not null");
Re: mysql -
TheArcher - 30.05.2012
Tried
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '%[]'", []);
to
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '\0'", []);
Re: mysql -
Mandrakke - 30.05.2012
Quote:
Originally Posted by TheArcher
Tried
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '%[]'", []);
to
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '\0'", []);
|
lol, it will never work. '\0' in mysql is a string and not a null value.
it seems that you are trying to verify if an field is null once this field does not accept null value.
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = ''", []);
Re: mysql -
BaubaS - 30.05.2012
Thank you so much.