enter SELECT id
, stock
, nombre
, CONCAT(descuento, '%') AS descuento
, CONCAT('$', FORMAT(precio, 2)) AS precio
, CONCAT('$', FORMAT(total, 2)) AS total
, tipo
FROM producto
WHERE stock >= 1
AND visto IS NULL
AND nombre LIKE 'materna%'
UNION ALL
SELECT id
, '' AS 'stock'
, nombre
, CONCAT('$', FORMAT(descuento, 2)) AS descuento
, CONCAT('$', FORMAT(precio, 2)) AS precio
, CONCAT('$', FORMAT(total, 2)) AS total
, tipo
FROM servicio AS s
WHERE visto IS NULL
AND nombre LIKE 'materna%'
这里
它显示的结果不对应
由于
答案 0 :(得分:0)
请尝试将LIKE
与通配符%
一起使用。请考虑UNION
而不是UNION ALL
来省略重复的行。在此处查看实时示例:SQL Fiddle。
SELECT id
, stock
, nombre
, CONCAT(descuento, '%') AS descuento
, CONCAT('$', FORMAT(precio, 2)) AS precio
, CONCAT('$', FORMAT(total, 2)) AS total
, tipo
FROM producto
WHERE stock >= 1
AND visto IS NULL
AND nombre LIKE 'materna%'
UNION
SELECT id
, '' AS 'stock'
, nombre
, CONCAT('$', FORMAT(descuento, 2)) AS descuento
, CONCAT('$', FORMAT(precio, 2)) AS precio
, CONCAT('$', FORMAT(total, 2)) AS total
, tipo
FROM servicio AS s
WHERE visto IS NULL
AND nombre LIKE 'materna%'
;