I need to SELECT based on the values in one of my array key fields.
我需要根据数组中的一个键字段的值来选择。
I have seen a few similar questions which were answered using a join but this didn't quite work for me.
我已经看到了一些类似的问题,这些问题都是用一个连接来回答的,但这对我来说并不是很有效。
Here's what I have so far;
这是我目前所拥有的;
$sku = join("','", $itemrow["SellerSKU"]);
$item_id =("SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE = ($sku);");
The error I'm getting is:
我得到的错误是:
Warning: join(): Invalid arguments passed
警告:join():无效的参数传递。
SOLVED:: In addition to the accepted answer this also worked;
解决::除接受的答案外,这也起作用;
I also managed this by re-jigging the statement and concatenating the variable; ("SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE = ".$itemrow["SellerSKU"].";
我还通过重新调整语句并连接变量来管理它;(“从“选择PRODUCT_ID .DB_PRODUCTS。”PRODUCT_CODE =”。美元itemrow(“SellerSKU”)。”;
2 个解决方案
#1
1
Instead, you IN
and implode
相反,你进入并内爆。
Try this-
试试这个,
$query= "SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE IN (" . implode(',', $itemrow["SellerSKU"]) . ")";
#2
1
$sku = implode(",", $itemrow["SellerSKU"]);
$item_id =("SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE in ($sku);");
#1
1
Instead, you IN
and implode
相反,你进入并内爆。
Try this-
试试这个,
$query= "SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE IN (" . implode(',', $itemrow["SellerSKU"]) . ")";
#2
1
$sku = implode(",", $itemrow["SellerSKU"]);
$item_id =("SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE in ($sku);");