|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
SELECT COUNT(*) FROM table1, table2
try that, because you have two table, you will only have 1 count. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
COUNT over two tables
Quote:
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; |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > COUNT over two tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|