#1

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.
Reply
#2

PHP код:
WHERE something IS NULL 
Reply
#3

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
Reply
#4

Yes, that should work. You can always quickly test queries in phpMyAdmin.
Reply
#5

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");
Reply
#6

Tried
pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '%[]'", []);
to

pawn Код:
mysql_format(_, Query, "SELECT `Something` FROM `table` WHERE `Something2` = '\0'", []);
Reply
#7

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` = ''", []);
Reply
#8

Thank you so much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)