HOW TO JOIN ON NULL VALUES IN SQL | Tricky SQL Problems | SQL Interview Questions
HTML-код
- Опубликовано: 6 сен 2024
- In these video, I am going to show you a trick in SQL.
I am going to show you how you can join on Null values in SQL.
CREATE TABLE `db`.`product_price` (
`pid` INT NULL,
`p_price` INT NULL);
CREATE TABLE `db`.`product_name` (
`pid` INT NULL,
`p_name` VARCHAR(30) NULL);
INSERT INTO `db`.`product_name` VALUES (1,"Apple");
INSERT INTO `db`.`product_name` VALUES (2,"Banana");
INSERT INTO `db`.`product_name` VALUES (3,"Mangoes");
INSERT INTO `db`.`product_name` VALUES (4,"Orange");
INSERT INTO `db`.`product_name` VALUES (NULL,"Kiwi");
INSERT INTO `db`.`product_price` VALUES (1,100);
INSERT INTO `db`.`product_price` VALUES (2,50);
INSERT INTO `db`.`product_price` VALUES (3,70);
INSERT INTO `db`.`product_price` VALUES (4,60);
INSERT INTO `db`.`product_price` VALUES (NULL,140);
INSERT INTO `db`.`product_price` VALUES (NULL,160);
Superb explanation 👌 👏 👍, very nice tricky question
we can also put kind of string also i believe so that it can join easily and we dont have to think of the number is there or not.
We explained 🎉
Looking forward more SQL scenario based questions
Great scenario...Please post more such problems