Concatenate multiple rows from one row from two databases
I have two tables in MySQL. One with orders. One with buyers. The buyers table is complex. I want to concatenate multiple rows from Buyers table into one row in my issue. This is what the tables look like what I am trying to achieve ... Is this possible?
ORDER TABLE
ID PRDCT_ID TITLE ORDER_TYPE
219 2 Product2 Shop_Order
220 2 Product2 Shop_Order
221 1 Product1 WH_Order
BUYER table:
ID ORDER_ID BUYER_KEY BUYER_VALUE
43 219 first_name Rebecca
44 219 last_name DeVore
45 219 email rebecca.devore@domain.com
46 220 first_name Jesse
47 220 last_name Lawrence
48 220 email jesse@domain.com
49 221 first_name Gary
50 221 last_name Darrel
51 221 email garydary@domain.com
Here I want the desired output to be ...
ORDERS.ID ORDERS.TITLE ORDERS.ORDER_TYPE "First Name" "Last Name" "Email"
219 Product2 Shop_Order Rebecca DeVore rebecca.devore@domain.com
220 Product2 Shop_Order Jesse Lawrence jessie@domain.com
221 Product1 WH_Order Gary Darrel garyday@domain.com
I haven't closed the code yet. I would call myself a MySQL newbie, but I know enough to make myself dangerous. But, just so you can laugh at my attempt ... here's where I am with the code; It works great to only return the lol name:
SELECT *
FROM BUYER a,
ORDERS b
WHERE a.post_id=b.id
AND b.post_type= "Shop_Order"
AND a.meta_key="first_name"
Edit; This question has been flagged as a duplicate. My question changes a bit. The answer to the question that this was marked as a duplicate suggests creating a new table in the database, which I cannot do. I will limit myself to these two tables only.
source to share
No one has answered this question yet
See similar questions:
or similar: