DataSource Controls :: Why We Need Union Query

Jun 10, 2010

if there is no relation bettwenn two tables why do i need union for example like below Please
can u inform me

SELECT categoryId
FROM categories
UNION
SELECT shipperId
FROM shippers

View 3 Replies


Similar Messages:

DataSource Controls :: Join Query Or Union?

Jun 30, 2010

i have two queries they are:
query1:
select CustID,NoOfChits from tblCust1 where [Group]='A' and CustID='a001'
query2:
select count(TKCustID) as Taken from tblAuctionGroup where [Group]='A' and TKCustID='a001'

Results of 1st query was:
----------
CustID NoOfChits
a001 2

Results of 2nd query was:
----------
Taken
4

But i want to like below:
--------------------------
CustID NoOfChits Taken
a001 2 4

in the above queries, 1st query displayed two columns and 2nd query displayed one column. but i would like to append the both results in single table or single record, i mean all results should be in same row in same result.

View 3 Replies

DataSource Controls :: Make Union Query Better?

Apr 11, 2010

in my application i should make an union query thay union 15 tables

and this query begin with 150000 rows and will grow .

i need get just 10 rows from this query

i want make this query as best as possible

2 qustion

-----------------------------------------------------------1------------------------------------------
********View1*******
select id, lang, active from table1
union
select id,lang,active from table2
...--same way to all other 15 tables
*******SP***********

select top 10 from View1 where active=1 and lang='he' order by id desc

or
********View1*******
select id, lang, active from table1 where active=1 and lang='he'
union
select id,lang,active from table2 where active=1 and lang='he'
...--same way to all other 15 tables
*******SP***********

select top 10 from View1 order by id desc

---------------------------------------------2---------------------------------------

becauseof that this query is very complicate i want to know if i need take just 10 from each table

------------------------------------------------3--------------------------------------

if there is an idea how make this query better, i will glad to know.

View 7 Replies

DataSource Controls :: Not Getting The Expect Result Set From Query / Join Or Union?

Jan 27, 2010

i have a form that my i use to look up whether or not there is an email address in the database. i wrote a query with this basic structure:

select *

from table A, table B

where table A.email = "email" or table b = "email"

i though that would return all instances that the email occurred in either table. what i am getting back is a bunch of null or other unrelated records from table A with a matching email in table B. the thing is, these two tables primary key to join them. i thought i wouldnt need to do that though in this case.

here is the actually query i am using if it makes things more clear:

select lm.cemailaddr, lm.b1emailadd, b.emailaddr

View 4 Replies

DataSource Controls :: How To Sort The Records When Using Union

Apr 8, 2010

how to sort the records when using union

View 2 Replies

ADO.NET :: How To Use Linq Query Union

Aug 31, 2010

I need to use Union for below Linq queries. I could use Union it if it was simple "select new whith{" but Now that I Specified Class, I encounter Error using union

[Code]....

View 3 Replies

DataSource Controls :: SQL Select Union And Total Number Of Returned Rows?

May 1, 2010

SQL Select Union and total number of returned rows?

View 3 Replies

SQL Server :: Simple Union Query / From Northwind Database

Aug 4, 2010

I am a .net developer.I am not that strong in SQL.I need a simple query.This is from Northwind Database.

select 'Select All' as CustomerID,'Select All' as City union(select CustomerID, City from Customers
order by City)

i need to get output like 1st row should be Select ALl Select All and next rows should be output of this stat..(select CustomerID, City from Customers order by City)

i am not getting this...i can do by keeping the second query result in temp table and then using union... but i am looking without temp tables or simple query.

View 2 Replies

Forms Data Controls :: Create A Lookup Data Source Based On A Union Query With The Actual Data And A Blank Record?

Jun 1, 2010

I'm new to ASP.net 3.5 and trying to create a test site so I can figure out how to use it in the real world. I have created a FormView (Formview1) based on a Client table using Linq Data Sources. The page includes a DropDownList to lookup Clients. I have added a list option (<asp:ListOption value="" Text="(Select Client)" and set AppendDataBoundItems=true so my added option is displayed. I decided to try to use Formview with only the Edit and Insert Modes, and I have set the Default Mode = Insert. When you open the page, a blank Client record is displayed.

The Client record contains serveral lookup fields and they have drop down lists for each. When I select a client from the Client DropDownList, is get the following message 'ddlClientType' has a SelectedValue which is invalid because it does not exist in the list of items I had this problem before and decided the best way to handle this (in the interim) was to turn off foreign key constraints for each of the lookup fields (e.g. ClientType) in SQL Server. That worked for 2-3 days. Now the problem has started again.

When I develop in other applications, I would simply create a lookup data source based on a Union Query with the actual data and a blank record. How can you do this using Linq DataSources. Can you get access and modify the queries?

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

[code]...

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 :: Not Able To Run SQL Query Using If Else?

Apr 21, 2010

I am using Querystring "ddl4" to pass on value of a drop down list to the next page where I am using that value in the WHERE clause of a SQL command. I also need to check whether ddl4 is blank or not which I do using If Else in SQL command. I am not able to run the query where the Querystring ddl4 IS NULL

This is the sample link with the Querystring ddl4 carrying a blank value:

[code]....

View 2 Replies

DataSource Controls :: How To Run Sql Query From Project

Apr 13, 2010

I have one query in my project (saved in folder SQLQueryes, Query.sql) and i need to execute it. Also, i have one parameter in script and i need to include him also. How?

View 8 Replies

DataSource Controls :: SQL Query With IF And Select

Feb 18, 2010

SQL Query with IF and Select

View 2 Replies

DataSource Controls :: Query Using Linq To Sql?

Jun 25, 2010

I´m using Linq to Sql in my asp.net application, but the problem is:I have a query like this:

[Code]....

My query is not returning anything, how do I do to get this?my problem is with this interval I need to have.

View 2 Replies

DataSource Controls :: Can't Use Query Effectively - First Name And Last Name

May 13, 2010

i want to know that should first name and last should be kept as sperate field or merged into single attribute. The Basic problem i am facing to keep first name and last name in seperate fields is that i cannot effectively use like query for searching a record by name

View 7 Replies

DataSource Controls :: Xml.query In Sql And No Records?

Mar 15, 2010

I have table in database with xml field and data like below

[Code]....

there are no records found

View 1 Replies

DataSource Controls :: Use A Parentheses In An SQL Query?

May 26, 2010

How do I use a Parentheses in an SQL query, example:

SET [myrow] = 'New Value' WHERE [myrow] = 'my (old) value'

View 2 Replies

DataSource Controls :: Use Login Name In A SQL Query?

Nov 24, 2010

I'm creating a web project in ASP.NET (C#) using Visual Studio 2010. I'm using the built-in login page. Here is what I'm trying to achieve.I want when a user logs in, the default.aspx page will display all his information including firstname, lastname, email address... I created a database table to store all users information (SQL). I want to use the "login name" as a parameter in "SELECT * FROM usertable WHERE username = loginname". From the code-behind (default.aspx.cs) I can pull the current loginname with "this.User.Identity.Name" but I can't pass this information to the query command in the default.aspx page.For example, when Jim logs in with his user name as "sirjim", I want to use"sirjim" in place of "loginname" in default.aspx page.Code in default.aspx page:

<asp:GridView
ID="GridView1"
runat="server"

[code]...

View 3 Replies

DataSource Controls :: Looking For Explanation Of Query ?

Feb 21, 2010

Hregarding to following query:

Use AdventureWorks

Go
ELECT p.ProductID,
piy.ProductID

What does mean ON 1 = 1 in this query??

View 3 Replies

DataSource Controls :: Get Sum In Single Query?

Jan 4, 2010

I have 2 tables table1 and table2 as given below.

Table1 - user master table. table2 - transaction table. Now I want to write a single query which will give results like table 3. how to write single query.

TABLE 1
TABLE 2
TABLE 3
USER ID

[Code]....

View 13 Replies

DataSource Controls :: SQL Query Formation?

Jun 11, 2010

I have several dropdowns in ASP.net, I want the contents in each dropdown depending on what is selected from the above dropdown and the datasource queries reflect this. I have the queries correct for the first two dropdowns, but I cannot get the third displaying data.

The first dropdown just contains all dept names

The second dropdown contains the manager names in that chosen dept above

The third is meant to contain the list employees relating to the chosen manager name above

<asp:Label ID="Label1" runat="server" Text="Cost Centre:" Font-Bold="True"></asp:Label>
<br />
<asp:DropDownList ID="DropDownList_CostCentres" runat="server" Height="21px"[code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved