General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 22nd, 2002, 05:00 PM
hick.hack hick.hack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 hick.hack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
COUNT over two tables

Hi,

I want to count over two tables like this

Code:
SELECT COUNT(table1.id), COUNT(table2.id) FROM table1, table2


but I got a wrong result.
What is wrong?

thanks for your help

cu hick.hack

Reply With Quote
  #2  
Old December 22nd, 2002, 06:44 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
SELECT COUNT(*) FROM table1, table2

try that, because you have two table, you will only have 1 count.

Reply With Quote
  #3  
Old December 23rd, 2002, 01:49 AM
hick.hack hick.hack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 hick.hack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sorry, but this is not what I want.

I will with one SELECT two different results one from every table.
Not a COUNT over both tables.

thanks for your time.

hick.hack

Reply With Quote
  #4  
Old December 23rd, 2002, 01:54 AM
hick.hack hick.hack is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 hick.hack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi, thanks all for your help.

I solve the problem.
This is the code that I want
Code:
SELECT COUNT(DISTINCT tabelle1.id) AS tbl1_length, 
COUNT(DISTINCT tabelle2.id) AS tbl2_length FROM tabelle1, tabelle2


cu hick.hack

Reply With Quote
  #5  
Old March 3rd, 2008, 06:02 AM
tamanti tamanti is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 1 tamanti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 43 sec
Reputation Power: 0
COUNT over two tables

Quote:
Originally Posted by hick.hack
Code:
SELECT COUNT(DISTINCT tabelle1.id) AS tbl1_length, 
COUNT(DISTINCT tabelle2.id) AS tbl2_length FROM tabelle1, tabelle2



Be careful! If the tables have many records this could result in an heavy query.

In an oracle environment I got better performance with:
Code:
select (select count(*) from table1) - (select count(*) from table2) from dual;

Reply With Quote
  #6  
Old July 10th, 2010, 08:53 PM
mannuthareja mannuthareja is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 2 mannuthareja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 52 sec
Reputation Power: 0
select (select count(*) from table1) - (select count(*) from table2) from dual;

This query is not working in MS-Access... Dual does not work in Access... Do you know how can this query run on Access?

Reply With Quote
Closed Thread

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > COUNT over two tables


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap