我正在使用下面的SQL查询来连接主表上的3个表
SELECT main.pricedrop,
t1.pid,
t2.pid,
t3.pid
FROM table_main AS main
LEFT JOIN table1 AS t1
ON main.pid = t1.pid
LEFT JOIN table2 AS t2
ON main.pid = t2.pid
LEFT JOIN table3 AS t3
ON main.pid = t3.pid
ORDER BY main.pricedrop ASC
LIMIT 5;
上面的查询给了我这个结果:
+-----------+---------+------+--------------+
| pricedrop | pid | pid | pid |
+-----------+---------+------+--------------+
| 8.69 | NULL | NULL | 665803977232 |
| 9.53 | NULL | NULL | 82210815 |
| 11.11 | 1786429 | NULL | NULL |
| 11.11 | 1786456 | NULL | NULL |
| 13.91 | NULL | NULL | 687074177857 |
+-----------+---------+------+--------------+
无论如何我可以得到这种格式的结果:
+-----------+--------------+
| pricedrop | pid |
+-----------+--------------+
| 8.69 | 665803977232 |
| 9.53 | 82210815 |
| 11.11 | 1786429 |
| 11.11 | 1786456 |
| 13.91 | 687074177857 |
+-----------+--------------+
答案 0 :(得分:4)
您需要使用COALESCE函数,该函数将返回第一个非空值,如:
customize.setLayout = function setLayout(text) { /* yada yada */ };
答案 1 :(得分:0)
JButton