tyweed Posted May 15, 2008 Share Posted May 15, 2008 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted May 15, 2008 Share Posted May 15, 2008 Your results will also contain betId (select b.*) but you haven't shown that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.