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 7841267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:03:55+00:00 2026-06-02T16:03:55+00:00

I have the following code, and database. My intent is the end user can

  • 0

I have the following code, and database. My intent is the end user can select the colums from a database (by ‘ajax’ing option/selects direct from mysql) and run a report on them. I can predetermine the tables they use, they pick the columns.
my biggest problem is the BEST way to perform a ‘schedule’ query.

To run a schedule i need the Details from ‘Customer’ and ‘Delivery’ – (customer info and delivery address) and i use the ‘custnum’ from all tables, plus the year, to choose which yearly schedule to run – ie custnum bar12345 – yearly schedule table is bar123452012

there could be 2 products per ‘custnum’ pulled from the bar123452012 table.

this table is just a single row per product, but 367 columns, 1- prodid, and 366 titled with the
yday
integer. php works out if it needs to use 365 or 366 in that year in a different function.

What would you suggest? A php loop to pull all customers one by one and format in a table, or is there an SQL query that will Left Join a different table to each row based on the tindex . 2012id?!
need speed and efficiency as we are talking at least 200 customer tables, maybe up to 1000.

Thanks to Dwurf for a reality check. Reorganised database to have one schedule table, and work from that.

Thanks Dwurf. New design being worked on all afternoon… Database

Table structure for table customer

custnum varchar(255) No
surname varchar(50) No
name varchar(50) No
phone1 varchar(50) No
phone2 varchar(50) No
email varchar(50) No
add1 varchar(50) No
add2 varchar(50) No
city varchar(50) No
postcode varchar(10) No

Table structure for table deliverydetails

special varchar(50) No
add1 varchar(50) No
add2 varchar(50) No
city varchar(50) No
postcode varchar(10) No
custnum varchar(100) No

Table structure for table notes

custnum varchar(50) No
notes varchar(50) No
time timestamp No CURRENT_TIMESTAMP

Table structure for table prodgroups

pgroup varchar(20) No
name varchar(50) No
description varchar(50) No

Table structure for table products

name varchar(50) No
quantity varchar(50) No
description varchar(50) No
pgroup varchar(50) No
price varchar(50) No
picture varchar(100) No
productid varchar(10) No
suppid varchar(50) No
vat tinyint(1) No

Table structure for table schedule

productid varchar(15) No

d0 varchar(100) No
d1 varchar(100) Yes NULL
d2 varchar(100) Yes NULL
…….
d362 varchar(100) Yes NULL
d363 varchar(100) Yes NULL
d364 varchar(100) Yes NULL
d365 varchar(100) Yes NULL

custnum varchar(50) No

id int(50) No

Table structure for table suppliers

suppid varchar(50) No
name varchar(50) No
phone1 int(100) No
phone2 int(100) No
email varchar(100) No
add1 varchar(50) No
add2 varchar(50) No
city varchar(50) No
postcode varchar(10) No
description varchar(100) No

Table structure for table vatgroups

vat int(20) No
amount decimal(20,0) No
description varchar(20) No

  • 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-02T16:03:56+00:00Added an answer on June 2, 2026 at 4:03 pm

    What would you suggest? A php loop to pull all customers one by one and format in a table,

    This approach is suicidal for performance

    or is there an SQL query that will Left Join a different table to each row based on the tindex . 2012id?!

    This isn’t really possible with the design you outline in your question. A design change might help though: if you have a single table for all of your reports and you add a column for the report name you will be a bit closer. Consider something like:

    Table structure for table Reports
    custnum varchar(255) No
    productid   varchar(15) No  
    date  DateTime    No  
    

    Now you can construct a query to grab all rows for a particular customer

    select * from Reports 
    where date between '2012-01-01' and '2013-01-01'
    and custnum = 'bob54326'
    

    Use PHP (or whatever you’re using) to generate the table from these results.

    I know this strategy breaks your ‘direct table access from UI’ model, but I’m afraid that model simply doesn’t work very well. Change your design to work with the tools you have instead of trying to force the tools to conform to your design.

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

Sidebar

Related Questions

I'm trying to select data from the database and I have the following code
I have the following code which deletes a record from a database. However I
I have following code class User attr_accessor :name end u = User.new u.name =
I have the following code to retrieve a dataset from a database. I would
I have the following code which takes an improperly saved Image from the database
i have the following code that generate some images with urls associated from database:
I have the following code that returns rows from a database when a form
I currently have the following code coming from a database table: <h1 class=widgetHeader>My Friends</h1>
I have the following code to insert items into a MySQL database from an
I have gridview binded from database.. I have following code: protected void Page_Load(object sender,

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.