我有两个表并使用了一个简单的查询:
SELECT * FROM innerb where not exists
(select * from wms where barcode = innerb.barcode) and pcode like '%102';
我的结果是这样的:
我需要为所有值添加一个逗号,使其看起来像这样:
但是我不想更新表或创建新表,只是想添加几秒钟。
有什么想法吗?
答案 0 :(得分:2)
您可以创建一个视图:
CREATE VIEW innerb_comma AS
SELECT CONCAT(Pcode, ',') AS Pcode,
CONCAT(Brand, ',') AS Brand,
CONCAT(Pdescription, ',') AS Pdescription,
CONCAT(Size, ',') AS Size,
CONCAT(Barcode, ',') AS Barcode
FROM innerb
WHERE NOT EXISTS (SELECT * FROM wms WHERE barcode = innerb.barcode)
AND Pcode like '%102';
然后从中进行选择:
SELECT * FROM innerb_comma
答案 1 :(得分:0)
SELECT pcode || ',' as pcode
, brand || ',' as brand
FROM table
编辑:仅适用于某些DB。显然不是MYSQL(除非您将其配置为工作)。 What does SQL Select symbol || mean?列出了适用于哪个数据库的列表