Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Multiple COUNT queries

Codes here !

Moderators: macek, egami, gesf

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
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 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?
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

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

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

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


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.