| | |
Same query, one difference
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
Hello!
I have a query with multiple table joints and where clauses. Tables are huge and query runs for a very long time. I need to run another query, which is exactly the same apart for one Where clause (first time price = "P", second time price = "S"). I use this for BIRT report, which means I need to have a result of there two queries at the same time. I can run them at the same time, but because they are both huge it takes a Long time. I wonder if I can make only one query, will it be faster? And if it will- what’s the best way to make it?
Thank you for your help!
Please let me know if it is not clear.
I have a query with multiple table joints and where clauses. Tables are huge and query runs for a very long time. I need to run another query, which is exactly the same apart for one Where clause (first time price = "P", second time price = "S"). I use this for BIRT report, which means I need to have a result of there two queries at the same time. I can run them at the same time, but because they are both huge it takes a Long time. I wonder if I can make only one query, will it be faster? And if it will- what’s the best way to make it?
Thank you for your help!
Please let me know if it is not clear.
Since you want to run exactly the same query and check only for one condition, you can do it this way.
So, by the end of the execution of this query, you will have 2 arrays, 1 with price=p values and the other with price=s values.
Cheers,
Naveen.
php Syntax (Toggle Plain Text)
$query="select * from huge_table where conditions joins etc"; $result=mysql_query($query); $price_p=array(); $price_s=array(); while($row=mysql_fetch_array($result,MYSQL_ASSOC)){ if($row['price']=="P"){ array_push($price_p,$row['price']); } if($row['price']=="S"){ array_push($price_s,$row['price']); } }
So, by the end of the execution of this query, you will have 2 arrays, 1 with price=p values and the other with price=s values.
Cheers,
Naveen.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
Thank you for your reply, but i wasn't clear.
Roughly my code:
And the second one is exactly the same apart from highlighted line (it▓s a.price_type='S')
I need a query, not a script.
Thank you so much.
Roughly my code:
MySQL Syntax (Toggle Plain Text)
SELECT * FROM sales_item d JOIN (SELECT STR_TO_DATE('2007-09-30', '%Y-%m-%d') st_date) v JOIN item_store f on f.item_no=d.item_no AND f.store_id = d.store_id JOIN item_sellprice_store a on f.item_no=a.item_no AND f.store_id = a.store_id JOIN item b on f.item_no=b.item_no JOIN item_supplier c on b.item_no=c.item_no AND b.supplier_no=c.supplier_no JOIN item_sellprice_storegroup g on a.batch_id=g.batch_id JOIN store k on f.store_id =k.store_id WHERE d.store_id = '011' AND (f.item_status ='A' OR f.item_status ='O') AND a.price_type='P' AND a.effective_start_date < v.st_date < a.effective_end_date AND d.sale_date = v.st_date ORDER BY d.category_code, a.sell_gst, a.item_no ;
And the second one is exactly the same apart from highlighted line (it▓s a.price_type='S')
I need a query, not a script.
Thank you so much.
Last edited by natashenka_66; Dec 3rd, 2007 at 5:46 pm.
Umm.. I didnt get you. Do you type this query in phpmyadmin/mysql prompt directly without using a php interface ? How do you generate a BIRT report ?What I said was, remove the condition and a.price_type='P' . Then compare the result with the price_type.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- My zipcode query is not returning the correct results (MS SQL)
- Difference between 2 dates by month (MS Access and FileMaker Pro)
- Query Cache (MySQL)
- Difference between Firefox and IE (JavaScript / DHTML / AJAX)
- need urgent help for a query (MS SQL)
- Microsoft Moviemaker Query (Windows Software)
- PHP/SQL query help (PHP)
Other Threads in the MySQL Forum
- Previous Thread: Problem on IF STATEMENT on TRIGGER with MySql
- Next Thread: New to databases
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






