add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
DROP TABLE IF EXISTS `clientorder`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clientorder` (
`clientorderid` int NOT NULL,
`clientid` int DEFAULT NULL,
`orderid` int DEFAULT NULL,
PRIMARY KEY (`clientorderid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `clientorder`
--

LOCK TABLES `clientorder` WRITE;
/*!40000 ALTER TABLE `clientorder` DISABLE KEYS */;
INSERT INTO `clientorder` VALUES (1,1,1);
/*!40000 ALTER TABLE `clientorder` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `clients`
--

DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
`clientid` int NOT NULL,
`name` varchar(3) DEFAULT NULL,
PRIMARY KEY (`clientid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Records: 2  Duplicates: 0  Warnings: 0
Records: 2  Duplicates: 0  Warnings: 0
SELECT c2.*,o.*
FROM
clients c2 LEFT JOIN (`orders` o LEFT JOIN
clientorder oc ON o.orderid = oc.orderid) ON c2.clientid = oc.clientid
union
SELECT c2.*,o.*
FROM
(`orders` o LEFT JOIN
clientorder oc ON o.orderid = oc.orderid) left JOIN clients c2 ON c2.clientid = oc.clientid

clientid name orderid name
1 c1 1 ds
2 x1 null null
null null 2 d