0

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

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"].";

1
  • What is it you are trying to achieve? Commented Aug 16, 2013 at 11:05

2 Answers 2

1

Instead, you IN and implode

Try this-

$query= "SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE IN (" . implode(',', $itemrow["SellerSKU"]) . ")";
Sign up to request clarification or add additional context in comments.

2 Comments

"...IN (" . implode(',', $itemrow["SellerSKU"]) . ")";
Worked using hjpotter92's solution! Will accept as soon as I can.
1
$sku = implode(",", $itemrow["SellerSKU"]);
$item_id =("SELECT PRODUCT_ID FROM ".DB_PRODUCTS." WHERE PRODUCT_CODE in ($sku);");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.