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

  • SEARCH
  • Home
  • 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 8195577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:11:04+00:00 2026-06-07T05:11:04+00:00

I have to make a report from very old mysql database (about year 2003).

  • 0

I have to make a report from very old mysql database (about year 2003). So the style is bad.
The structure is that table have columns: id, type, field, value. In these fields are all information but for one id there are many entries. If normally data would be stored like this: id, name, speed, service, project etc, then in this table data is stored like: id (used for many rows), type, field (here is placed name, speed, service …. but just one of them), value (value of field ‘field’).
But I need to combine this table data for each id (where are multiple entries with each id) with table where are connections between tables and then combine with third table (which actually is the same table as first but with different id). I wrote a script but it is awfully slow, PHP cannot execute it in 30 seconds. Maybe some directions in which I should write script?

Table “Base”:

id | type | field | value

Table “Connects”:

master | slave

I get data from table “base” filtering by “type”, then getting first row and correct data, then looping while “master” from table “connects” points to “base” item with “type” which I need and get correct data.
And full script which is too slow:

http://paste.php.lv/ce693aee64e9617b509e336b25e3262f?lang=php

  • 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-07T05:11:06+00:00Added an answer on June 7, 2026 at 5:11 am

    You do it with JOINs.

    “Normal” query:

     SELECT SUM(value) FROM products WHERE product_name = "stanchion";
    

    “Your” query, if I have understood correctly:

     SELECT SUM(v.value) FROM bigtable v JOIN bigtable p ON (v.key = p.key AND v.field = "value" AND p.field = "product_name" ) WHERE p.value = "stanchion";
    

    You may want to translate the whole bigtable in a multicolumn table:

     CREATE TABLE translated [AS]
     SELECT v.key AS product_id, v.value AS value,
         p.value AS product_name,
         s.value AS stock,
         ...
         FROM bigtable v
         JOIN bigtable p ON (v.key = p.key AND v.field = "value" AND p.field = "product_name" )
         JOIN bigtable s ON (v.key = s.key AND v.field = "value" AND s.field = "stock" )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a make table query that is used to run a report (due
I have a very simple Crystal report document which pulls data from a db
I have a very simple report in SSRS that is just a table with
I have been struggling to make a set of reports that gives the sum
Using this sample : I have make my own Fragment that holds tabhost and
I have to make a page that look like painting below, but: field 1
I have a crystal report that shows sales volumes called week to date volume.
I am aware that questions about recurring events are common but I have not
I have a report that renders a report header on its own page and
I have a very strange bug in a shipping iPad/iPhone app that I can't

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.