473,796 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting a filtered group result

3 New Member
hey

I'm trying to make a query which selects all rows that are not linked to the a certain number, i already managed to do this with a subquery, but this slows down the application, mainly caused because i have more then 100k rows.

Expand|Select|Wrap|Line Numbers
  1. (simplefied) table
  2. ############################
  3. # RowId # MessageId # Type #
  4. ############################
  5. # 1     # 104       # 3    #
  6. # 2     # 104       # 3    #
  7. # 3     # 104       # 4    #
  8. # 4     # 104       # 5    #
  9. # 5     # 104       # 4    #
  10. # 6     # 104       # 8    #
  11. # 7     # 105       # 3    #
  12. # 8     # 105       # 2    #
  13. # 9     # 105       # 1    #
  14. # 10    # 106       # 4    #
  15. # 11    # 106       # 3    #
  16. # 12    # 107       # 4    #
  17. # 13    # 107       # 6    #
  18. # 14    # 107       # 5    #
  19. # 15    # 107       # 9    #
  20. ############################
  21.  
so, a Message consists out of several types, now i want to select the messageId's that do not contain the type: 8,9 or 1. which is in this case message 106

is there any way to do this without a subquery?

Greetz Daanoz
Jan 17 '08 #1
4 1249
Delerna
1,134 Recognized Expert Top Contributor
Just a suggestion as I don't know the full details of your situation. It may or may not be possible for you

When I find that doing subqueries on large tables is too slow then I look to see
if I can bring a reduced number of records from the table into a table variable

I then perform the suquerying operation on the table variable instead.

Also you may have already done this so again, just suggesting, but do you have good indexes on the table.
Regards
Jan 17 '08 #2
daanoz
3 New Member
Just a suggestion as I don't know the full details of your situation. It may or may not be possible for you

When I find that doing subqueries on large tables is too slow then I look to see
if I can bring a reduced number of records from the table into a table variable

I then perform the suquerying operation on the table variable instead.

Also you may have already done this so again, just suggesting, but do you have good indexes on the table.
Regards
Sadly i'm not allowed to make any changes to the database, it's read-only because it's used by a bunch of other applications (not my choice ;))
Jan 17 '08 #3
daanoz
3 New Member
ok... solved by letting my PHP script set-up subresults, so the sub query doesn't have to be repeated time after time, but just once

Greetz Daanoz
Jan 17 '08 #4
ck9663
2,878 Recognized Expert Specialist
ok... solved by letting my PHP script set-up subresults, so the sub query doesn't have to be repeated time after time, but just once

Greetz Daanoz
the catch: you have to make sure your resultset is updated by the time it's accessed

-- CK
Jan 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
3704
by: Ben Gribaudo | last post by:
Hello! I am trying to query a MySQL table and retrieve either the earliest or the latest message in each thread. The messages are in a table with MsgID being the primary key and fThreadID identifying to which thread the message belongs. Examples below. Any ideas on the SQL I need to use here?
13
4025
by: Tony | last post by:
Hi everyone, I am new to javascript (and new to programming). I want to have to drop down menus. One will ask use to select from one of the 50 states. The second one will be ask user to select a county within that state, but will completely invisible (and unpopulated) until user selects a state. I've been looking for code to do this in JavaScript, but I haven't found any. Can anyone help me?
4
4740
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student athletes.  I have now learned how to join two different tables in a query so that I might generate a report. Specifically, student athletes at a community college are required to graduate with an AA or AS degree.  Consequently, various steps are in...
2
4806
by: origin197511 | last post by:
Hello all... I'm having an issue with MSAccess 2000. I have a Form that holds records of my cartridge loads for a rifle and a subform that lists all groups that have been fired with that load. They are linked by the load_id field and when I just browse through the loads everything shows up correctly. Each recorded group is displayed on a line of the datasheet subform. However, when I filter the form for say my "Selected" flag...
6
2058
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I need to use parts of the tables in datagrids, and here is where my problem lies
4
16604
by: Tmuld | last post by:
Hello, I have a complete table within a dataset. I want a dataview to show particular filtered data - works great with the dv.rowfilter. But can I display only certain columns that are filtered? Right now in my rowfilter I have something like this:
7
5474
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when looping through the GridView, it doesn't
4
6150
by: monomaniac21 | last post by:
hi! is it possible to do the aforementioned query - selecting only distinct in 1 col but retrieving all other cols at the same time. regards marc
2
1362
by: Henrik Goldman | last post by:
Hi there, I'm new to sql and thus I'm having problems with a specific query which I hope you guys can help me with. Basicly I have a few tables which I'm trying to do a query on: Table groups contains information about specific groups e.g. "Windows" or "Unix". Table users contains information about specific users e.g. "a", "b" or "c".
1
3989
by: Ralf | last post by:
Hi, i try to find a query for selecting one arbitrarily chosen row from each group of rows. Example: $ db2 "select * from T" A B C
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.