[英]Mysql compare IP address from table
I have a query in which i wanted to compare the ip address of system with the existed ip in records of table. 我有一个查询,我想将系统的IP地址与表记录中存在的IP进行比较。 but not able to compare the ip .. when i use normal query for counting records it works but not with Ip address in Where clause. 但无法比较ip ..当我使用普通查询计数记录时,它可以工作,但不能与Where子句中的IP地址一起使用。 my query is as below 我的查询如下
SELECT count(product_id) AS count_likes, product_count FROM
'._DB_PREFIX_.'count_likes WHERE product_id = '.$product_id.' AND ip-address =
"'.trim($ip_address).'";
I just want o compare ip and count no of matching records. 我只想o比较ip,不计算匹配记录。
so far i got a just small mistake, So would like to post here 到目前为止,我只犯了一个小错误,所以想在这里发布
below is my modified query 下面是我修改后的查询
$sql = 'SELECT * FROM '._DB_PREFIX_.'count_likes WHERE `product_id` =
"'.$product_id.'" AND `ip_address` = "'.$ip_address.'"';
It has back quote difference to the column name ... Thanks to all for reply. 它具有与列名不同的引号。...感谢所有人的答复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.