join results in mysql

1

Hello I hope you can help me  the truth is that I do not know how I can unite the results

SELECT 
    p.SKU,
    p.pt_part,
    p.pt_color,
    p.pt_talla,
    p.pt_draw,
    p.pt_promo,
    p.pt_desc1,
    p.pt_rev,
    o.pod_part,
    o.po_nbr,
    o.vd_sort,
    o.po_vend,
    o.po_ord_date,
    o.pod_contract,
    o.pod_qty_ord,
    o.pod_qty_rcvd

FROM 
    productos as p
JOIN 
    ordenes as o
ON 
    p.SKU = o.pod_part 
WHERE
    p.SKU like '11111111110338' 
    and p.pt_promo like 'INV2017' 

The idea is that I can search by code, color and size separately and can search for something like that

p.pt_part like '111111111' and p.pt_color like '103' and p.pt_talla like '38' and this is complete 11111111110338 so that the values can match with the other table

    
asked by Francisco 23.02.2017 в 13:57
source

2 answers

0

Al final era asi ( SELECT p.SKU, p.pt_part, p.pt_color, p.pt_talla, p.pt_draw, p.pt_promo, p.pt_desc1, p.pt_rev, o.pod_part, o.po_nbr, o.vd_sort, o.po_vend, o.po_ord_date, o.pod_contract, o.pod_qty_ord, o.pod_qty_rcvd FROM productos as p LEFT JOIN ordenes as o ON p.SKU = o.pod_part WHERE p.pt_part = '111111111' and p.pt_color = '105' and p.pt_talla = '38' and pt_promo = 'inv2017'")

    
answered by 02.03.2017 / 13:10
source
1

You can use the CONCAT function to concatenate fields in the output:

SELECT 
    p.SKU,
    CONCAT(p.pt_part, p.pt_color, p.pt_talla) concatenacion,
    p.pt_part,
    p.pt_color,
    p.pt_talla,
    p.pt_draw,
    p.pt_promo,
    p.pt_desc1,
    p.pt_rev,
    o.pod_part,
    o.po_nbr,
    o.vd_sort,
    o.po_vend,
    o.po_ord_date,
    o.pod_contract,
    o.pod_qty_ord,
    o.pod_qty_rcvd

FROM 
    productos as p
JOIN 
    ordenes as o
ON 
    p.SKU = o.pod_part 
WHERE
    p.SKU like '11111111110338' 
    and p.pt_promo like 'INV2017' 
    
answered by 23.02.2017 в 14:01