» 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 08-29-2006, 03:21 PM
zeus zeus is offline
OSP Starters
 
Join Date: Jun 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
zeus is on a distinguished road
Default Distinct Question

I have two tables

campaign table
[ id][ name][region ]...
[ 1][######][ 0]
[ 2][######][ 0]
[ 3][######][ 0]

data table
[id ][campaign][location]...
[ 1][ 1][#####]
[ 2][ 2][#####]
[ 3][ 1][#####]

SELECT DISTINCT(data.campaign), data.id, data.location FROM data , campaign WHERE campaign.region = '0' AND data.campaign = campaign.id LIMIT 4;

What the end result would be
Results
[ 1][ 1][#####]
[ 2][ 2][#####]

But it is
Results
[ 1][ 1][#####]
[ 2][ 2][#####]
[ 3][ 1][#####]

Does anyone know how I can get it to return only on result for each campaign id? -- 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 08-29-2006, 03:23 PM
ROLAND ROLAND is offline
OSP Starters
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ROLAND is on a distinguished road
Default

DISTINCT is not a function, it applies to all the columns in the SELECT

where did you learn to use it like a function? you aren't the first to do that, and i wish i could find whichever book or website tutorial is teaching this, because it's just flat out wrong

Code:
select campaign.id
, data.id
, data.location
from campaign
inner
join data
on data.campaign = campaign.id
and data.id =
( select min(id)
from data
where campaign = campaign.id )
where campaign.region = 0
order
by campaign.id limit 4 -- 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
Question on payout of ads services Brkcitylove Google 3 06-07-2007 10:21 AM
Question about combining two DB records into one ASP Table richardson ASP forums and Tips 1 08-29-2006 02:35 PM
Question about combining two DB records into one ASP Table richardson ASP forums and Tips 0 08-29-2006 02:34 PM
Welcome to distinct on OutSourcingPlans... osp Introductions 1 08-02-2006 05:15 PM
google language question monika Google 1 03-25-2006 01:14 PM


All times are GMT. The time now is 11:28 AM.