The results are not as i desired using foreach loop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
$warehousesArray = array('Paharganj' => '5',
'Sant Nagar'=>'11324',
'Mumbai'=>'35798',
'UP Border'=>'117262',
'Top Floor'=>'170740',
'Gurgaon'=>'170741');
$stockSummaryQuery1 = " SELECT
p.productid,
p.productname,
scf.cf_976 AS stock_quantity,
w.warehousename,
SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs
FROM vtiger_products AS p
LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid
LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid
LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid
JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid
AND stockent.deleted = 0
LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924
JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid
JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900
JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid
JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid
LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 ";
if (isset($_GET['vendor_name']) && !empty($_GET['vendor_name'])) {
$warehouseid_array = explode("_", $_GET['vendor_name']);
$warehouseid = $warehouseid_array[0];
$stockSummaryQuery1 .= " AND v.vendorid = ".$warehouseid;
}
foreach ($warehousesArray as $key => $value) {
echo $stockSummaryQuery1.= " AND w.warehousesid = $value";
echo "<br><br><br><br>";
}
$stockSummaryQuery1 .= " GROUP BY p.productid ASC";
i have echo the queries and the result is
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324 AND w.warehousesid = 35798
My desired result is the warehouseid is only written once and the values changes from 5
to 11324
and then 35798
php sql join
add a comment |
$warehousesArray = array('Paharganj' => '5',
'Sant Nagar'=>'11324',
'Mumbai'=>'35798',
'UP Border'=>'117262',
'Top Floor'=>'170740',
'Gurgaon'=>'170741');
$stockSummaryQuery1 = " SELECT
p.productid,
p.productname,
scf.cf_976 AS stock_quantity,
w.warehousename,
SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs
FROM vtiger_products AS p
LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid
LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid
LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid
JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid
AND stockent.deleted = 0
LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924
JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid
JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900
JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid
JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid
LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 ";
if (isset($_GET['vendor_name']) && !empty($_GET['vendor_name'])) {
$warehouseid_array = explode("_", $_GET['vendor_name']);
$warehouseid = $warehouseid_array[0];
$stockSummaryQuery1 .= " AND v.vendorid = ".$warehouseid;
}
foreach ($warehousesArray as $key => $value) {
echo $stockSummaryQuery1.= " AND w.warehousesid = $value";
echo "<br><br><br><br>";
}
$stockSummaryQuery1 .= " GROUP BY p.productid ASC";
i have echo the queries and the result is
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324 AND w.warehousesid = 35798
My desired result is the warehouseid is only written once and the values changes from 5
to 11324
and then 35798
php sql join
mb you should useOR
instead ofAND
in theWHERE
sectionWHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)
– Oleksandr Pobuta
Nov 22 '18 at 8:38
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59
add a comment |
$warehousesArray = array('Paharganj' => '5',
'Sant Nagar'=>'11324',
'Mumbai'=>'35798',
'UP Border'=>'117262',
'Top Floor'=>'170740',
'Gurgaon'=>'170741');
$stockSummaryQuery1 = " SELECT
p.productid,
p.productname,
scf.cf_976 AS stock_quantity,
w.warehousename,
SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs
FROM vtiger_products AS p
LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid
LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid
LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid
JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid
AND stockent.deleted = 0
LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924
JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid
JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900
JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid
JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid
LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 ";
if (isset($_GET['vendor_name']) && !empty($_GET['vendor_name'])) {
$warehouseid_array = explode("_", $_GET['vendor_name']);
$warehouseid = $warehouseid_array[0];
$stockSummaryQuery1 .= " AND v.vendorid = ".$warehouseid;
}
foreach ($warehousesArray as $key => $value) {
echo $stockSummaryQuery1.= " AND w.warehousesid = $value";
echo "<br><br><br><br>";
}
$stockSummaryQuery1 .= " GROUP BY p.productid ASC";
i have echo the queries and the result is
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324 AND w.warehousesid = 35798
My desired result is the warehouseid is only written once and the values changes from 5
to 11324
and then 35798
php sql join
$warehousesArray = array('Paharganj' => '5',
'Sant Nagar'=>'11324',
'Mumbai'=>'35798',
'UP Border'=>'117262',
'Top Floor'=>'170740',
'Gurgaon'=>'170741');
$stockSummaryQuery1 = " SELECT
p.productid,
p.productname,
scf.cf_976 AS stock_quantity,
w.warehousename,
SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs
FROM vtiger_products AS p
LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid
LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid
LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid
JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid
AND stockent.deleted = 0
LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924
JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid
JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900
JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid
JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid
LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 ";
if (isset($_GET['vendor_name']) && !empty($_GET['vendor_name'])) {
$warehouseid_array = explode("_", $_GET['vendor_name']);
$warehouseid = $warehouseid_array[0];
$stockSummaryQuery1 .= " AND v.vendorid = ".$warehouseid;
}
foreach ($warehousesArray as $key => $value) {
echo $stockSummaryQuery1.= " AND w.warehousesid = $value";
echo "<br><br><br><br>";
}
$stockSummaryQuery1 .= " GROUP BY p.productid ASC";
i have echo the queries and the result is
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324
SELECT p.productid, p.productname, scf.cf_976 AS stock_quantity, w.warehousename, SUM(IF(scf.cf_974=scf.cf_976 AND scf.cf_974 != 0,1,0)) AS number_of_packs FROM vtiger_products AS p LEFT JOIN vtiger_productcf AS pcf ON pcf.productid = p.productid LEFT JOIN vtiger_stockscf AS scf ON scf.cf_922 = p.productid LEFT JOIN vtiger_stocks AS s ON scf.stocksid = s.stocksid JOIN vtiger_crmentity AS stockent ON stockent.crmid = s.stocksid AND stockent.deleted = 0 LEFT JOIN vtiger_racks AS ra ON ra.racksid = scf.cf_924 JOIN vtiger_rackscf AS racf ON ra.racksid = racf.racksid JOIN vtiger_rooms AS ro ON ro.roomsid = racf.cf_900 JOIN vtiger_roomscf AS rocf ON rocf.roomsid = ro.roomsid JOIN vtiger_warehouses AS w ON rocf.cf_910 = w.warehousesid LEFT JOIN vtiger_vendor AS v ON v.vendorid = p.vendor_id WHERE 1 AND w.warehousesid = 5 AND w.warehousesid = 11324 AND w.warehousesid = 35798
My desired result is the warehouseid is only written once and the values changes from 5
to 11324
and then 35798
php sql join
php sql join
edited Nov 22 '18 at 8:41
Corion
3,35911226
3,35911226
asked Nov 22 '18 at 8:35
GauravGaurav
12
12
mb you should useOR
instead ofAND
in theWHERE
sectionWHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)
– Oleksandr Pobuta
Nov 22 '18 at 8:38
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59
add a comment |
mb you should useOR
instead ofAND
in theWHERE
sectionWHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)
– Oleksandr Pobuta
Nov 22 '18 at 8:38
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59
mb you should use
OR
instead of AND
in the WHERE
section WHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)– Oleksandr Pobuta
Nov 22 '18 at 8:38
mb you should use
OR
instead of AND
in the WHERE
section WHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)– Oleksandr Pobuta
Nov 22 '18 at 8:38
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426790%2fthe-results-are-not-as-i-desired-using-foreach-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426790%2fthe-results-are-not-as-i-desired-using-foreach-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
mb you should use
OR
instead ofAND
in theWHERE
sectionWHERE 1 AND (w.warehousesid = 5 OR w.warehousesid = 11324 OR w.warehousesid = 35798
)– Oleksandr Pobuta
Nov 22 '18 at 8:38
Welcome to Stack Overflow! Please provide a relevant and minimal sample data showcasing your requirements, and expected output. Please go through this link once: Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Madhur Bhaiya
Nov 22 '18 at 8:59