Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:32:31+00:00 2026-06-03T00:32:31+00:00

I have a successful query that currently returns all data except for one table.

  • 0

I have a successful query that currently returns all data except for one table. The last table contains meta data where it is a one to many relationship (one product, multiple records with related data).

Is there a way to append a field with a value to the end of an existing query so that I can still access the record set in PHP with a mysql_fetch_array() command?

essentially I want to query for any records with the product ID, and then append multiple additional fields.

After thinking about it i was actually wondering if I can include an array within the records set (i.e. the array of results for the meta data) and access that through PHP?

Working Query:

SELECT offers.*, c.short_name AS sponsorName, c.logo AS sponsorLogo 
FROM offers LEFT JOIN sponsors AS c ON c.id=offers.sponsor ORDER BY end_date ASC

Results:

ID: 43875
category: 1
state: CO
city: Denver
zip: 80221
sponsor: 1
title: The coolest thing ever
duration: 2 years
price: 10
frequency:: Month

Second query that gets the right meta data-

SELECT mo.`name` AS meta_value FROM offer_metas 
LEFT JOIN meta_options AS mo ON mo.id = offer_metas.meta_option 
WHERE offer_id='48735' ORDER BY meta_option ASC

results:

meta_value:
'5-10 tickets'
'General Admission'

I want to add those two fields to the record up top .. but don’t know how to append all fields within a query result into a single already existing record.

–SOLVED–

Query has been adjusted to account for GROUP_CONCAT as follows

SELECT
offers.*,
s.short_name AS sponsorName,
s.logo AS sponsorLogo,
GROUP_CONCAT( mn.title) titles,
GROUP_CONCAT( mo.`name`) metas
FROM offers
LEFT JOIN sponsors AS s ON s.id = offers.sponsir
INNER JOIN offer_metas ON offer_metas.offer_id = offers.id
INNER JOIN meta_options as mo ON offer_metas.meta_option = mo.id
INNER JOIN meta_names as mn ON mo.category = mn.category AND mo.cat_seq = mn.seq
ORDER BY end_date ASC

data results looked good including 2 fields called “titles” and “metas” that looked like this

titles: 'Number of Tickets,Purchased Seats'
metas: '5-10,General Administration'

now THOSE .. I can work with in PHP .. and since they have the same number of elements i’ll just parse them into an array i can better work with 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:32:32+00:00Added an answer on June 3, 2026 at 12:32 am

    Further to your comments above, it sounds like GROUP_CONCAT() will give you what you’re after. It won’t return the meta_values as an array, but rather as a string (e.g. with each value separated by <br/> in order that they can be emitted directly as HTML):

    SELECT
      offers.*,
      c.short_name AS sponsorName,
      c.logo AS sponsorLogo,
      GROUP_CONCAT(mo.name ORDER BY meta_option ASC SEPARATOR '<br/>') AS meta_values
    FROM
      offers
      LEFT JOIN sponsors     AS c  ON c.id       = offers.sponsor
      LEFT JOIN offer_metas  AS o  ON o.offer_id = offers.id
      LEFT JOIN meta_options AS mo ON mo.id      = offer_metas.meta_option
    ORDER BY end_date ASC;
    

    Note that, if you need to escape the meta values for any HTML they might contain, you’ll need to choose a different separator (perhaps U+001E, INFORMATION SEPARATOR TWO?) and have PHP replace that separator with suitable HTML after escaping any contained HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic query that returns around 590,000 records. It runs successfully the
I have been successful at rounding my value to one decimal point, but I
I have some XML data retrieved from a web service that I use to
I currently have the following MySQL query, which I would like to include in
We currently have a SOAP based web service that our in house applications use
I have an archive page template that I've built that has a successful navigation
I have approximately 7 terabytes of various media files (pdf's, jpg's, tiff's) that currently
R version: 2.12.2 / OS: Windows XP Data that I need to query and
I need to used dynamic order query in mysql and i have successfully achieved
I have modified my MOSS 2007 configuration to query a given target AD successfully.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.