Combining MySQL queries
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Combining MySQL queries

  1. #1
    Join Date
    Jul 2011
    Location
    .NET 3.5
    Posts
    40

    Combining MySQL queries

    Hello, I have 2 queries that I will be running in my PHP script. The time it takes to run them are very long. I have a data of 1.8m rows in the table.
    So, I would like to know if it is possible to join these 2 queries into one or any other ways of making them faster?
    The queries are as below:

    (
    SELECT call_date as call_date, call_uniqueid as call_uniqueid,call_duration as raw_duration, telephone_numbers as account_number,
    telephone_numbers_tariffname as tariffname, telephone_numbers_destination as destination, telephone_numbers_call_amount as call_amount,
    telephone_numbers_call_duration as call_duration, callerid as callerid, outbound as outbound, called_number as called_number
    FROM billing_table
    where (reseller1 = '001-000001' ) and (timeinlong BETWEEN '1326470400' AND '1339689599')
    ORDER BY timeinlong DESC
    LIMIT 0, 10
    )
    union
    (
    SELECT '-' as call_date, '-' as call_uniqueid, '-' as raw_duration, '-' as account_number, '-' as tariffname, '-' as destination,
    round(sum(telephone_numbers_call_amount),4) as clientcost, sum(telephone_numbers_call_duration_in_secs) as totalcallduration,
    '-' as callerid, '-' as outbound, '-' as called_number
    FROM billing_table
    WHERE (reseller1 = '001-000001' ) and (timeinlong BETWEEN '1326470400' AND '1339689599')
    )

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,840

    Re: Combining MySQL queries

    [ moved thread ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center