数据库查询问题

WBOY
Release: 2016-06-23 14:26:10
Original
880 people have browsed it

$asin=$_POST['key'];$sql="SELECT t.`item_code`,t.`package_area`,t.`asin`,t.`sku`,b.`pack_weight` ";$sql.="FROM `1_sku_comparison` t left join `1_product` b on t.`item_code`=b.`item_code` ";$sql.="WHERE t.`sku`='".$asin."' OR t.`asin`='".$asin."' OR t.`item_code`='".$asin."'";
Copy after login


现在的问题是当t.`item_code`=$asin这个条件满足时能查出数据,t.`sku`='".$asin."' OR t.`asin`='".$asin."'这两个条件满足时,就报没查到数据,但是我输出$sql后,用输出的$sql在phpmyadmin能查到数据。我是用ajax传值的,请问这是什么情况呢??


回复讨论(解决方案)

where t.`sku`='".$asin."'  and (t.`asin`='".$asin."' OR t.`item_code`='".$asin."')";
Copy after login

$sql.="WHERE t.`sku`='".$asin."' and (t.`asin`='".$asin."' OR t.`item_code`='".$asin."')";

t.`sku`='".$asin."' OR t.`asin`='".$asin."' OR t.`item_code`='".$asin."'";

我是要这个条件,问题是,现在执行结果是item_code可以查出来,asin和sku字段条件满足时查不出来

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!