1
我想找到一種方法來構建SQL查詢。我需要的數據在兩個表中,包含3條記錄,但我需要以某種方式返回,以便稍後可以將它作爲1條記錄插入到表中。該查詢將在PHP中使用,所以我也願意使用它。以下是我有:個別比賽將MySQL查詢結果合併到單個記錄中
SELECT ID, meta_key, meta_value
FROM wp_posts
INNER JOIN wp_postmeta
ON wp_posts.ID = wp_postmeta.post_id
WHERE post_status = 'publish'
AND post_date >= CURDATE()
AND post_type IN ('tribe_events', 'tribe_organizer', 'tribe_venue')
AND meta_key IN ('_EventStartDate', '_EventEndDate', '_OrganizerOrganizer', '_OrganizerWebsite', '_VenueAddress', '_VenueCity', '_VenueState', '_VenueZip')
嘗試GROUP_CONCAT() – 2012-11-15 03:42:33