1

I am having an issue with the code below and my issue is the following:

I need to be able to select the shop_shipping_rule_region_code if the country_iso is NULL but I also need to get the $country_iso data as well if present

What I am after:

The Final Result will have:

Overnight UPS
NZ Snail Mail
Whole World (in this example)

DB:

`shop_shipping_rules` (`shop_shipping_rule_id`, `shop_shipping_rule_country_iso`, `shop_shipping_rule_region_code`, `shop_shipping_rule_name`, 
    `shop_shipping_rule_type_single`, `shop_shipping_rule_item_single`, `shop_shipping_rule_type_multi`, 
    `shop_shipping_rule_item_multiple`,`shop_shipping_rule_created`, `shop_shipping_rule_modified`, `website_id`)
     VALUES
    (41, 'NZ', 'ALL', 'Overnight UPS', 'single', 2.00, 'multi', 4.00, '2013-11-05 02:30:19', '2013-11-05 03:00:27', 64),
    (44, 'NZ', NULL, 'NZ Snail Mail', 'single', 25.00, 'multi', 35.00, '2013-11-14 03:57:06', NULL, 64),
    (45, NULL, 'ALL', 'Whole World', 'single', 90.00, 'multi', 150.00, '2013-11-14 05:05:53', NULL, 64),
    (46, NULL, 'EU', 'EU Ship', 'single', 28.00, 'multi', 35.00, '2013-11-15 01:04:01', NULL, 64);
2
  • The top half of the question seems to be talking about selection and references a variable, the bottom half is an insert. Are you asking for help with a SELECT statement? If so, can you show us what you currently have? Commented Nov 20, 2013 at 7:26
  • @Damien_The_Unbeliever yes I am wanting to write a select statement I have also removed the insert as this was just to show the db table Commented Nov 20, 2013 at 7:31

1 Answer 1

1
if (isset($country_iso))
   $sql = "SELECT * FROM shop_shipping_rules WHERE country_iso IS NULL OR country_iso = '$country_iso' ";
else
    $sql = "SELECT * FROM shop_shipping_rules WHERE country_iso IS NULL";
Sign up to request clarification or add additional context in comments.

1 Comment

$country_iso = "'; DROP TABLE `shop_shipping_rules` --";

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.