473,503 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can anyone pls help me to join tis 2 query statement

28 New Member
1. select * from MyDataBase
2. select count(*)as total_child,direct_mngr_personnel_number as personnel_number from MyDataBase group by direct_mngr_personnel_number

both of the query statement is came from same table

i need it into 1 so that i can call it to dataSet..
Pls....
help me....
i hav no idea already....
Aug 4 '08 #1
6 1615
debasisdas
8,127 Recognized Expert Expert
If both the query return similar column list and datype you can go for UNION.
Aug 4 '08 #2
simonyong
28 New Member
If both the query return similar column list and datype you can go for UNION.

ya..i tried it just now...but cant because of "group by"

debasisdas,
may i ask that is it possible if i use left join?
Aug 4 '08 #3
arachno
9 New Member
Maybe you're looking for something in the likes of this:

Expand|Select|Wrap|Line Numbers
  1. SELECT direct_mngr_personnel_number, and_the_other_columns_you_need, totalcount.total_child
  2. FROM MyDataBase
  3. INNER JOIN (SELECT COUNT(*) AS total_child, direct_mngr_personnel_number FROM MyDataBase
  4. GROUP BY direct_mngr_personnel_number) totalcount
  5. ON MyDataBase.direct_mngr_personnel_number = totalcount.direct_mngr_personnel_number
  6.  
On the last line I took a wild guess that direct_mngr_personnel_number is your primary key. If it's not, change it to your primary key.
Aug 5 '08 #4
amitpatel66
2,367 Recognized Expert Top Contributor
ya..i tried it just now...but cant because of "group by"

debasisdas,
may i ask that is it possible if i use left join?
What is the error that it is displaying??
Aug 5 '08 #5
simonyong
28 New Member
Maybe you're looking for something in the likes of this:

Expand|Select|Wrap|Line Numbers
  1. SELECT direct_mngr_personnel_number, and_the_other_columns_you_need, totalcount.total_child
  2. FROM MyDataBase
  3. INNER JOIN (SELECT COUNT(*) AS total_child, direct_mngr_personnel_number FROM MyDataBase
  4. GROUP BY direct_mngr_personnel_number) totalcount
  5. ON MyDataBase.direct_mngr_personnel_number = totalcount.direct_mngr_personnel_number
  6.  
On the last line I took a wild guess that direct_mngr_personnel_number is your primary key. If it's not, change it to your primary key.

yaya...similiar tat....
Aug 6 '08 #6
simonyong
28 New Member
Thx for giving me idea, i had done it successfully with following:

select a.*, b.total_child from MyDataBase a left join (select direct_mngr_personnel_number as personnel_number, count(*) as total_child from MyDataBase group by direct_mngr_personnel_number) b on a.personnel_number = b.personnel_number where lower(a.firstname) like '%" + TextBox1.Text.ToLower.Replace("'", "''") + "%' and lower(a.lastname) like '%" + TextBox2.Text.ToLower.Replace("'", "''") + "%'order by " + DropDownList1.SelectedValue.ToString + " asc"
Aug 6 '08 #7

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

Similar topics

7
43638
by: Barry Young | last post by:
I am using Access to create a SQL query. It creates an Inner Join Query. I cut and paste the query into PL-SQL. When I try to execute the query I get an error. ORA 933 SQL command not properly...
0
3049
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
13
1886
by: kieran | last post by:
Hi, I have the following SQL statement which is pulling a few details from a database. As you can see, there is only the one table from which i am creating a temporary copy. The reason I do...
7
2898
by: stabbert | last post by:
I am attempting to join two tables together on two different unix servers. Here is some relevant info about the tables. TABLE 1 Setup ----------------------- DB2 UDB 7.2 EE
14
6078
by: Ryan | last post by:
I want to do the following SQL statement in Access. However, it won't allow me to have the secondary part of my join statement and tells me that this is not supported. OK, so Access doesn't support...
6
9281
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
52
6269
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
3
16492
by: Zeff | last post by:
Hi all, I have a relational database, where all info is kept in separate tables and just the id's from those tables are stored in one central table (tblMaster)... I want to perform a query, so...
14
2478
by: cjakeman | last post by:
Hi, Solved a little mystery yesterday when I built a form that combined 2 tables with a 1:M relationship and relational integrity. All the correct data was visible on the form but, if I tried to...
3
2682
by: rrstudio2 | last post by:
If I have two tables and need to do a left outer join and include a where statement on the second table, it seems like the left outer join becomes an inner join. For example: Table: Names id...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7348
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...
1
7006
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...
0
5592
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,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1519
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 ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
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...

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.