0

The following code below gives me a result of

enter image description here

but how do I make it so that I get a result of

enter image description here

Code:

SELECT * FROM `shop_shipping_rules` LEFT JOIN `countries` ON `shop_shipping_rules`.shop_shipping_rule_country_iso = `countries`.iso 
LEFT JOIN `shop_shipping_regions` ON `shop_shipping_regions`.shop_shipping_rule_region_code = `shop_shipping_rules`.shop_shipping_rule_region_code
WHERE `website_id` = 64 AND `shop_shipping_rule_name` IS NOT NULL

1 Answer 1

2

In your predicate, filter out empty fields.

AND `shop_shipping_rule_name` IS NOT NULL AND `shop_shipping_rule_name` <> ''

It's also best practice to stay away from SELECT * and use a column list. Also, you should use aliases and be explicit with your columns.

You will probably want to go through these and make the empty values NULL:

UPDATE `shop_shipping_rules` 
SET `shop_shipping_rule_name` = NULL 
WHERE `shop_shipping_rule_name` = ''
Sign up to request clarification or add additional context in comments.

1 Comment

OR should be AND.

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.