This topic is locked
[SOLVED]

 Multiable Tables Report

2/26/2016 7:58:41 AM
PHPRunner General questions
gehrenfeld author

I have two tables.

  1. Glucose reading
  2. insulin
    I want to create one report called Logbook that list each record from the tables sorted by date.
    Example:
    12/01/16 12:30AM 120 (This from the glucose table)

    12/01/16 12:25 50 Units (This is from the insulin table)
    There is a lot more data in each record but just wanted show basically what I want to do.
    These tables have no relationship to each other, nor do I want one.
    Thanks for any help.

Sergey Kornilov admin 2/26/2016

This can be done. Normally this can be done via UNION SQL Query that allows you to combine data from several unrelated tables. Since PHPRunner doesn't support UNION queries you will need to create a view in your database on the top of this SQL Query.
Assuming that your database is MySQL here are relevant links:

http://dev.mysql.com/doc/refman/5.7/en/create-view.html

http://dev.mysql.com/doc/refman/5.7/en/union.html
And here is a complete example for you:

CREATE VIEW vw_product_services AS

SELECT DISTINCT products.pid AS id,

products.pname AS name,

products.p_desc AS description,

products.p_loc AS location,

products.p_uid AS userid,

products.isaproduct AS whatisit

FROM products

UNION

SELECT DISTINCT services.s_id AS id,

services.s_name AS name,

services.s_desc AS description,

services.s_uid AS userid,

services.s_location AS location,

services.isaservice AS whatisit

FROM services
gehrenfeld author 2/27/2016



This can be done. Normally this can be done via UNION SQL Query that allows you to combine data from several unrelated tables. Since PHPRunner doesn't support UNION queries you will need to create a view in your database on the top of this SQL Query.
Assuming that your database is MySQL here are relevant links:

http://dev.mysql.com/doc/refman/5.7/en/create-view.html

http://dev.mysql.com/doc/refman/5.7/en/union.html
And here is a complete example for you:

CREATE VIEW vw_product_services AS

SELECT DISTINCT products.pid AS id,

products.pname AS name,

products.p_desc AS description,

products.p_loc AS location,

products.p_uid AS userid,

products.isaproduct AS whatisit

FROM products

UNION

SELECT DISTINCT services.s_id AS id,

services.s_name AS name,

services.s_desc AS description,

services.s_uid AS userid,

services.s_location AS location,

services.isaservice AS whatisit

FROM services



Just what I needed thank you