I have two tables.
Table First
+----+---------+-------+
| ID | Name | URl |
+----+---------+-------+
| 1 | Product | http1 |
+----+---------+-------+
| 2 | Cheif | http2 |
+----+---------+-------+
| 3 | Client | http3 |
+----+---------+-------+
Table Second
+-----+----------------+-------------+
| ID | Dashboard | Definition |
+-----+----------------+-------------+
| 1.1 | Product,Cheif | Overview |
+-----+----------------+-------------+
| 2.1 | Cheif | malpractice |
+-----+----------------+-------------+
| 3.1 | Client,Product | Vanity |
+-----+----------------+-------------+
I am expecting output
+----+----------------+-------------+-------------+
| ID | Dashboard | Definition | Url |
+----+----------------+-------------+-------------+
| 1 | Product,Cheif | Overview | http1,http2 |
+----+----------------+-------------+-------------+
| 2 | Cheif | malpractice | http2 |
+----+----------------+-------------+-------------+
| 3 | Client,Product | Vanity | http3,http1 |
+----+----------------+-------------+-------------+
I tried with split using if, locate, substring then creating view, only to find alias cannot be used on where clause.
split logic is as below.
SELECT IF(
LOCATE(‘,’, `dashboard`) > 0,
SUBSTRING(`dashboard`, 1, LOCATE(‘,’, `dashboard`) - 1),
`u_dashboard`
) AS memberfirst,
IF(
LOCATE(‘,’, `dashboard`) > 0,
SUBSTRING(`dashboard`, LOCATE(‘,’, `dashboard`) + 1),
NULL
) AS memberlast
FROM `table`;