Query based on the other query data [message #357899] |
Fri, 07 November 2008 01:47  |
redfuel
Messages: 1 Registered: November 2008
|
Junior Member |
|
|
Hi,
I have a situation where first query is executed and based upon this query data I am executing second query to get multiple records. These second query returns multiple records and I need to show these multiple records with first query record using some colspan in HTML. So basically all records contains another queries multiple records.
The problem is, let's say If I have 5000 records in first query then second query getting executed 5000 times and it is badly hitting the performance. Another way to achieve this using JOINs but in join query I will get records with data for all attributes of first query.
Please suggest if there any other good way to achieve this to boost the performance.
- Fuel
|
|
|
|
Re: Query based on the other query data [message #357911 is a reply to message #357899] |
Fri, 07 November 2008 03:00  |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
I'd use analytics.
Specifically, I'd use the LAG function on the parent table to compare the current primary key value with the previous primary key value, and if they're different, then display the values for that row.
Have a try at writing a query like that, and if you have difficulties, we'll give you some more pointers.
|
|
|