Announcement

Collapse
No announcement yet.

How control the printing if no record in the details.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How control the printing if no record in the details.

    Hi to All,
    I have 2 tables linked master/details.
    For example:
    Master Table
    account_id Integer;
    account_name varchar;
    account_address varchar;
    etc....
    Details
    account_id integer;
    number_id integer;
    telephone_number varchar;
    etc...

    I have created a report that must print for each account the telephone numbers. And all work.
    The problem is that are printed also all the accounts without telephone numbers.
    This is the code in the report:
    PHP Code:
              /*------------------ Page 1 -----------------*/
                
    sc_pdf_print($cell_companyname);
                
    sc_pdf_print($cell_companyaddress);
                
    sc_pdf_print($cell_companycountry);
                
    sc_pdf_print($cell_companytelephon);
                
    sc_pdf_print($cell_account_id);
                
    sc_pdf_print($cell_accountcode);
                
    sc_pdf_print($cell_accountlastname);
                
    sc_pdf_print($cell_accountfirstname);
                
    sc_pdf_print($cell_accountaliasname);
                
    sc_pdf_set_y(85);
                foreach ({
    numbers_detail} as $NM_ind => $Dados)
                { 
                    
    sc_pdf_print_sub_sel($cell_numbers_detail_number_tel[$NM_ind]);
                    
    sc_pdf_print_sub_sel($cell_numbers_detail_aggregate_number[$NM_ind]);
                    
    sc_pdf_print_sub_sel($cell_numbers_detail_description[$NM_ind]);
                    
    sc_pdf_ln(4);
                }
              
    /*-------------------------------------------*/ 
    The SQL Select is:
    Code:
    SELECT 
        companyname,
        companyaddress,
        companycountry,
        companytelephon,
        accountcode,
        accountlastname,
        accountfirstname,
        accountaliasname,
        account_id
    FROM 
        vw_header_numbers_x_account
    ORDER BY account_id
    The Select in the field numbers_details is:
    Code:
    SELECT 
        account_id,
        number_tel,
        aggregate_number,
        description
    FROM 
        vw_body_numbers_x_accounts
    WHERE 
       (account_id = {account_id})
    ORDER BY account_id
    Please how can print only the accounts that have details ? I hope in your help.
    Last edited by nicosia; 04-07-2013, 03:18 AM. Reason: SOLVED
    Thank You and Best Regards
    Gaetano

  • #2
    Solved

    I have solved using the condition WHERE EXISTS (SELECT.......) in the SQL.
    Bye
    Thank You and Best Regards
    Gaetano

    Comment

    Working...
    X