php - Combine Two Rows in MySQL to Show Data as One Row -


i want join woocommerce created post meta fields show first , last name of client in 1 row.

the table structure of mysql follow:

meta_id    post_id    meta_key                meta_value =======    =======    =======                 =========== 1234       1874       _billing_first_name     john 1235       1874       _billing_last_name      cobe 

now want return following results using mysql statement

post_id    _billing_first_name    _billing_last_name =======    ====================   ================== 1874       john                   cobe 

looking forward suggestions , help.

thanks.

if have 2 fixed values meta_key, can use this:

select   post_id,   max(case when meta_key='_billing_first_name' meta_value end) _billing_first_name,   max(case when meta_key='_billing_last_name' meta_value end) _billing_last_name   yourtable group   post_id 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -