Jump to content

Select Distinct query returning repeated rows please help i'v searched first!


tyweed

Recommended Posts

Ok I have this query

 

Select Distinct b.*,g.groupname,g.user_id from betstable as b, user_id_groupname as g WHERE betCreator in (1,2,4,6,'Open') AND betBetween in (1,2,4,6,'Open')

 

and it is returning :

dateBet nameBet BetBetween|BetCreator Amount Winner Groupname

11-24-2008 test again jon | ken 4 jon test

11-24-2008 test again jon | ken 4 jon test2

11-24-2008 test again jon | ken 4 jon test

11-24-2008 test again jon | ken 4 jon test

11-24-2008 test again jon | ken 4 jon test

02-Apr-2008 test1 tyweed | ken 4 ken test

02-Apr-2008 test1 tyweed | ken 4 ken test2

02-Apr-2008 test1 tyweed | ken 4 ken test

02-Apr-2008 test1 tyweed | ken 4 ken test

02-Apr-2008 test1 tyweed | ken 4 ken test

 

tables look like the following

 

--------------Betstable------------------------------

nameBet betBetween amount winner betId betCreator dateOfBet

test Open 5 1 5 24-Apr-2008

test again 2 4 4 6 4 11-24-2008

test1 2 4 2 2 1 02-Apr-2008

test 2 2 4 1 3 1 02-Apr-2008

testy Open 45 4 2 02-Apr-2008

fffffffffffffffffffffffffffffffffff 1 23456 5 2 05-Apr-2008

 

 

 

 

--------user_id_groupname-------------------

 

id user_id groupname

1 1 test

2 1 test2

3 2 test

10 4 test

18 6 test

 

------------------------------------------

 

The query is suppose to return all bets in the betstable where a user_id of betBetween,betCreator are in the same group.

 

essentially only show bets where users are in the same group as the user which in this case was 1,2,4,6, open Open is a bet anyone can view. I kinda understand why it is repeating but i'm unsure how to get these same results but only showing 1 unique row for every bet. It seems to repeat every bet the number of results were found. So if six fit the query logic it repeats every find six times?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.