DataSource Controls :: How To Optimize Query With Multiple Inner Joins

Mar 22, 2010

I have one question regarding how to make the below mentioned type of query more optimized so that mine query perfomace can be increased.

Select a.name1,a.address1,b.field3,c.field4,d.field6,e.field7
from a
inner join b on
inner join c on
inner join d on
iner join e on
union all
Select a1.name1,a1.address1,b1.field3,c.field4,d.field6,e.field7
from a1
inner join b1 on
inner join c on
inner join d on
iner join e on
union all
Select a2.name1,a2.address1,b2.field3,c.field4,d.field6,e.field7
from a2
inner join b2 on
inner join c on
inner join d on
iner join e on

All the above three select query at last using the same inner join condition, means last two inner join condition are the same for all the select query.

Is there any way so that this query can be optimized?

View 2 Replies

Similar Messages:

DataSource Controls :: Optimize My Sql Query In Sql 2005?

Mar 23, 2010

I am working on a project where in one SQL query i am using joins to fetch data from diffrent tables. The execution time of the query is 20 seconds for 80 rows on my local server. How can i optimize this.

View 3 Replies

DataSource Controls :: Running SQL Query From SQL Management Studio - Optimize?

Jun 29, 2010

I have one query which is not responding even after 4 minutes. But same query is when called from pages (though stored procedure), responds within 10 seconds. My Query:


I don't want to know the ways to optimize the query as I have already changed the query and now it responds within fraction of second. I just want to know that, why it was not reponding after 4 minutes in SQL Management Studio and responds in just 10 seconds when run from through stored procedure. I am using SQL 2008 Express with Advanced services and .NET 3.5.

View 4 Replies

SQL Server :: Slow Running Query Based On Multiple Tables Using Joins

Nov 15, 2010

One of my peer wrote a query based on multiple tables using joins. One of the table is in a different database The query was taking much time

1. Create an SP
2. Create a temp table and copy all records from the external db
3. Avoid using Left Join as much as possible and use Inner Join
4. Create and use indexes
5. Remove tables/columns that are not necessary

In this scenario, I would like to suggest to use Covering Index, but how can it be created for multiple tables and a temp table?

View 3 Replies

C# - LINQ To Entity Framwework Multiple Joins With Multiple Dynamic Search Criteria?

Jul 2, 2010

The gist of the problem is that we have an alumni table (one record per person) and also a couple of other tables (one to many) that have degree info and interest info. In a search screen in our app you can search for criteria that spans all three tables (there are actually more fields and tables than shown in the example below but I am trying to keep it simple).

The code below works (properly returns people without degrees for example) but still feels a little clunky or over-engineered to me. Are there easier ways to do this? NOTE: I have been through quite a few iterations/approaches to making the correct data be returned.


View 1 Replies

DataSource Controls :: SQL Select Inner Joins Using Count

Mar 17, 2010

I have a SQL select statement with inner joins to get a total number of records for the statement. I have tried using count with group by's but it just counts one for each record instead of giving me the total number of records for the query. Here is the query:


View 3 Replies

DataSource Controls :: Cross Context Joins In Linq?

Jun 21, 2010

I have a requirement where i need to combine tables from two different datacontext. Does Cross context is allowed in Linq??

i wrote a linq query but its throwing error.

View 5 Replies

SQL Server :: Both Keyword Using Joins In A Single Query?

Jul 29, 2010

Is it possible to have ON and WHERE , both keyword using Joins in a single query

View 6 Replies

ADO.NET :: LINQ To SQL - Multiple Joins With Multiple Conditions?

Jan 28, 2011

I have some problems trying to query my database. The problem is that I'm not sure how to multiple join tables in my database.

tables to make it easier:


What I'm supposed to do is to find all the teachers (predavac) who were teachers on the specific activity (aktivnost) and who had specific attendee (polaznik). The problem is I'm not sure how to do multiple joins on this one.

View 1 Replies

DataSource Controls :: Multiple Like Statements In One Select Query

Mar 15, 2010

I need to write a select query where it will be doing "like" on one column with multiple strings.

Eg : Select * from tblCity where city like '%ABC%' and city like '%XYZ%'

I have set of strings.

View 5 Replies

DataSource Controls :: Using Multiple Values In A Parametrized Query?

Aug 13, 2010

SELECT ClientMaster.ClientName,*
FROM ProjectMaster LEFT JOIN ClientMaster
ProjectMaster.RefCode IN (@refcode) AND ProjectMaster.ProjectStatus=@status

@refcode should be able to contain multiple values but how should I pass value to the parameterized query?

I have tried many ways such as @refcode = 'VALUE1','VALUE2', @refcode = VALUE1,VALUE2 but to no avail?

View 3 Replies

DataSource Controls :: Repeating A Nested (or Sub) Query For Multiple Categories?

Jul 10, 2010

I'm trying to design a page that displays all suppliers by their location. I'd quite like this to work from a query that will automatically include new locations added in the future.

At the moment my design has a table that holds 'locations' with locationID and locationName fields. In my 'suppliers' table I also have a locationID to join them.

I'm not sure how to query the database to return all the suppliers in location 1, then all in location 2. (Or even sure of the terms I need to Google to get some examples!) For example:

Location 1
Supplier 1
Supplier 2
Location 2
Supplier 3
Supplier 4

View 3 Replies

DataSource Controls :: How To Pass Multiple Values And Execute Query In Stored Procedure

Jun 2, 2010

basically i have two dropdown boxes to filter data and textbox with stored procedure bound to gridview.i want to be able to query data depending on the selected value passed,either using one or more parameter values.

i would like seperate sqlcommands to chose from depending on which controls i select to pass parameters.

i have included a parameter Select(control id) as this is declared by the wizard for stored procedure.

but i am not sure how it is defined on the page and passed to procedure.


View 2 Replies

Web Forms :: How To Give Multiple Inner Joins To Single Table In SQL Server

Oct 30, 2012

how to give a multiple inner joins to the single table

View 1 Replies

DataSource Controls :: SqlDataSource And Parameters Query / Trying To Accomplish Is Building Dynamic Query

Aug 22, 2010

1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like

SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.

Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).

2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query

(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).

If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.

View 11 Replies

DataSource Controls :: Update Query Not Working When Using Query Builder To Configure Table Adapter

Jan 15, 2010


This query works perfectly on the query analyser.

But when configuring the Table adapter ,I try executing the query and i get 0 rows affected.

What could I be getting wrong in this case.

NB:Existing GalleryID has been supplied.

View 1 Replies

DataSource Controls :: Can't Find Query's / By Right Clicking On Database Created A Query In Server Explorer?

May 17, 2010

By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.

View 10 Replies

DataSource Controls :: How To Convert Sql Query Into Linq Query

Mar 10, 2010

select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid

View 5 Replies

DataSource Controls :: Accessing FK From A Query Via Entity Query

Jan 21, 2010

I've got a query such as

Dim MediaQuery =
From m
In dB.DOWNLOADS _Where m.ID = id _Select

which returns a record from the database. One of the fields in the record is a FK to another table. I need to read this value to be able to set a dropdown based on the ID but I can't work out how to access it. For a standard record I can just do the following txtTitle.Text = MediaQuery.FirstOrDefault().TITLE

However with the foreign key it doesn't work like that. I've tried drpGroup.SelectedIndex = MediaQuery.FirstOrDefault().DOWNLOAD_GROUPS.ID where DOWNLOAD_GROUPS is the FK field but it returns Object reference not set to an instance of an object. If you're simply wanting to read some values from a single db record in the entitiy framework and one is a foreign key how should I go about getting the value?

View 2 Replies

DataSource Controls :: How To Create Multiple Records In A Dataset From Multiple Databases

Mar 7, 2011

I am trying to design my logic to do this but I want to create a dataSet which will have records from several databases, The records all have the same layout.

I am reagin the connection string paths from a table in a database.

I am asking for your help in trying figure out my logic.

Should I use the connectionString builder in conjunction with a loop to Connect, read a record into a dataset Until therer are no more records to be read from my databse table with the database name/paths tables ?

Here is my beginning code which deals with one database:


View 2 Replies

DataSource Controls :: Multiple Result Sets Vs Multiple Data Readers?

Jun 4, 2010

Would it be better to have a sp return multiple result sets and use NextResult() or have subsequent call to dr.execute.... () and hadle one result at a time?

To me using nextResult() on a multiresult datareader would be cleaner and easier - but it does not seem to be very "atomized". I guess I am wondering can the cost of executing multiple commands be neglected? Seems like executing multiple commands and receiving a single result set would also be easier to read/test/understand.

View 1 Replies

SQL: Selecting From Multiple Tables In One Query Or A Query For Each Table?

Mar 6, 2011

A follow up question concerning the DAL layer part .. The first question about dealing with large objectsI have one table (PlacesTable) that is connected by like 6 other tables (1:Many and Many:Many relations)

In my DAL should I put a big query that join the 6 tables + the m:m reference tables (btw it produces multiple data that I don't need Please refer to my old question) and place all the data in it's specific object property or, should I use a single query for each table and create an object for each fetched table .. and finally send those to the UI ?If I wasn't clear enough please let me know what I further information do you need to know!

View 4 Replies

Forms Data Controls :: Bind Linq (including Inner Joins) To GridView?

Mar 14, 2010

Executed a linq query, and now needs to bind it to the gridview. here is code that doesn't bind anything currently:


View 3 Replies

Forms Data Controls :: How To Return Multiple Rows From A Query

May 18, 2010

I have the below c# method to populate an frontend control from a linq query. The only valid way I seem to be able to reference the query variable "result" is if I use the attribute "SingleOrDefault" but unfortunately this forces my query to return just the one single set of data for every unique primary key UserId value from my query, where I require the unique data attached to each different UserId value to be returned, how can I achieve this using linq? Note, I am passing the UserId value into my method from a public variable which is also below.


View 4 Replies

Forms Data Controls :: Select Query In In Multiple Conditions?

Mar 6, 2010

i create view in sql server and execute a select query using AND operator on it using and bind data with gridview...but i am not getting result in grid

View 3 Replies

Copyrights 2005-15, All rights reserved