'using cross join but data doesn't appear
A table
| idx | dy | mark |
|---|---|---|
| 1 | 5 | ch |
| 2 | 7 | ox |
B table
| idx | name | d5 | d6 | d7 | d8 |
|---|---|---|---|---|---|
| 1 | star | NULL | ok | NULL | ok |
im using cross join to make relation B table to A table, but data can't appear.. my sql :
SELECT
A.name,
IFNULL(A.d5 IS NULL, CASE WHEN 5=B.dy THEN 'pr' END) AS `D5`
IFNULL(A.d6 IS NULL, CASE WHEN 6=B.dy THEN 'pr' END) AS `D6`
IFNULL(A.d7 IS NULL, CASE WHEN 7=B.dy THEN 'pr' END) AS `D7`
IFNULL(A.d8 IS NULL, CASE WHEN 8=B.dy THEN 'pr' END) AS `D8`
FROM
A,B
I hope to generate data like this:
|idx|name|D5|D6|D7|D8|
|:---:|:---:|:---:|:---:|:---:|:---:|
|1|star|pr|ok|pr|ok|
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
