MYSQL_ROW是什么数据类型_“MYSQL_ROW行”数据类型

本文探讨了在使用MySQL进行查询时遇到的数据类型不匹配问题,特别是当试图将MySQL查询结果与整数进行比较时出现的问题。文章提供了如何解决这一问题的具体步骤,并讨论了可能的数据类型转换方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bd96500e110b49cbb3cd949968f18be7.png

The reason this is not working is that MYSQL_ROW row and an integer of 1 or 0 are not of the same data type. How would i make them the same data type?mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = ''192.168.1.399'' AND Status = ''Active''");

my_ulonglong i = 0;

res_set = mysql_store_result(conn);

my_ulonglong numrows = mysql_num_rows(res_set);

{

row = mysql_fetch_row(res_set);

if (row[i] = 1) //////THIS IS THE ISSUE??????/////////

printf("YES: %s\n",row[i]);

else

printf("NO: %s\n",row[i]);

}

mysql_free_result(res_set);

mysql_close(conn);

system("PAUSE");

/*End Works*/

}

解决方案Take a look at the documentation here[^], which explains the data types returned by MySQL functions. mysql_fetch_row() returns a database row not an integral value.

first off...

in an if statement:

if(x = 1) //

if(x == 1) //

second (assuming the rest of your code is kosher, i''m pretending it is)...

you have to look up what MYSQL_ROW is typedef''ed from, if its an int, then a comparator should work, but if you need to cast it, you need to do an explicit cast (usually if you have to do this you should know what you''re doing as far as data types, could lead to crashes, bugs, or loss of data):

MYSQL_ROW row;

int x= (int) row; //

//In a statement

if(x == row) //

if(x == (int)row) //

I''d help you more with the SQL portion of it but its been years since I last did SQL.

*****Update:*****

int value; //

int row[10]; //

if(row == 1) //

if(row[2] == 1) //

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值