473,657 Members | 2,283 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,dir ect_mngr_person nel_number as personnel_numbe r from MyDataBase group by direct_mngr_per sonnel_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 1623
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_per sonnel_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_per sonnel_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_per sonnel_number as personnel_numbe r, count(*) as total_child from MyDataBase group by direct_mngr_per sonnel_number) b on a.personnel_num ber = b.personnel_num ber where lower(a.firstna me) like '%" + TextBox1.Text.T oLower.Replace( "'", "''") + "%' and lower(a.lastnam e) like '%" + TextBox2.Text.T oLower.Replace( "'", "''") + "%'order by " + DropDownList1.S electedValue.To String + " asc"
Aug 6 '08 #7

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

Similar topics

7
43668
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 ended. It highlights the INNER JOIN statement on the SQL command. Can someone recommend a utility to convert these Microsoft or Access SQL queries to PL SQL? Thanks!
0
3062
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 solve my problem. I'll turn to MySQL doc after getting through this pressing project. Thanks a lot Roger! Babale -----Urspr=FCngliche Nachricht-----
13
1902
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 this is because in the table i only have the 'standIn' listed by integer and i want to return the 'standIn' by name. I hope this is clear enough.
7
2910
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
6089
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 it, but there must be an alternative. I can add the part 'D.Dealer_Code' to the where clause, but because of the way that the statement is executed, it excludes data that I want. My SQL statement is perfectly leagal and works fine, but Access...
6
9304
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: tblEmployees empId -- EmpName -- EmpRole -- EmpManager -------....------------.... ---------....--------------- 1........ dan yella..........1..........2
52
6312
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 variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
3
16502
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 all data from the separate tables is shown in a view (instead of the reference id's pointing to the separate tables...) I have some troubles formulating the SQL statement: I tried:
14
2488
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 edit any of the fields, the PC bleeped. Seems it was due to the query the form was based on. Again, editing any of the fields of the query caused the PC to bleep.
3
2690
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 Name StatusCode 1 John 11 2 Henry 22 3 Bob 33
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
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
8739
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...
0
8613
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...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2740
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
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.