Multiple COUNT queries

Codes here !

Moderators: macek, egami, gesf

User avatar
mammal
New php-forum User
New php-forum User
Posts: 37
Joined: Wed Apr 02, 2003 1:31 am
Location: Hythe, UK

Multiple COUNT queries

Postby mammal » Thu May 01, 2003 7:13 am

I'm trying to count the distinct fields within two tables, but my script keeps timing out. Any ideas:

SELECT COUNT(DISTINCT table1.fieldname) AS table1, COUNT (DISTINCT table2.fieldname) as table2 FROM table1, table2

Ideally I want one total but two would do. Any ideas?

Thanks in advance

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Thu May 01, 2003 7:54 am

SELECT DISTINCT COUNT(table1.fieldname) AS table1, DISTINCT COUNT (table2.fieldname) as table2 FROM table1, table2

hows that?

User avatar
mammal
New php-forum User
New php-forum User
Posts: 37
Joined: Wed Apr 02, 2003 1:31 am
Location: Hythe, UK

Postby mammal » Fri May 02, 2003 7:53 am

I want it to count distinct fields, this will not do that.

Thanks anyhoo


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest