» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 07-31-2006, 04:22 PM
lara lara is offline
Junior Member
 
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
lara is on a distinguished road
Default Counting results from a union

hi buddy

SELECT DISTINCT brand, docsource, doctype, effect
FROM brands
WHERE brand LIKE 'a%' AND docsource = 'MTM' AND docid NOT LIKE '%3.htm'

UNION

SELECT DISTINCT brand, docsource, doctype, effect
FROM brands
WHERE brand LIKE 'a%' AND docsource = 'cons'

UNION

SELECT DISTINCT brand, docsource, doctype, effect
FROM brands
WHERE brand LIKE 'a%' AND docsource = 'pdr'
ORDER BY brand

I want to return a subset of this query for displaying on a page (using LIMIT 0,100), but also want to know how many records there are in total. Is there a way of doing this without returning all the records and counting them in PHP? I want to minimise the data sent between PHP and MySQL, just for cleanliness.

thanx -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 07-31-2006, 04:24 PM
harva harva is offline
Junior Member
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
harva is on a distinguished road
Default

SELECT DISTINCT
SQL_CALC_FOUND_ROWS
brand, docsource, doctype, effect
FROM brands
WHERE brand LIKE 'a%'
AND (
docsource = 'MTM' AND docid NOT LIKE '%3.htm'
OR docsource IN ( 'cons','pdr' )
)
ORDER
BY effect LIMIT 100
;
SELECT FOUND_ROWS(); -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
please discuss your experience.. regarding search results. parjapat MSN 2 09-18-2006 10:57 AM
How to get rid of supplementory results from Google? yardy Google 2 08-29-2006 11:27 AM
Upgrading results in slower... Hana MySQL Forums 1 08-21-2006 06:49 AM
Lower search results elance Google 2 07-22-2006 01:30 PM
European Union Community at .eu Domain War outsourcingplans Web Hosting Industry 0 02-08-2006 07:25 PM


All times are GMT. The time now is 10:53 AM.