Discussion:
beginning sql join (?) help
(too old to reply)
m***@gmail.com
2015-01-19 16:17:42 UTC
Permalink
I have two tables, data and users

data holds account information, one field called midd which defines ownership based on acctmin and acctmax fields in users

i want to pull data.* and users.*, but only limit it to where data.midd is >= 0 and <= 33. when i'm trying to write my sql query, i'm getting duplicates (becuase my results give more records than data has) and i've no doubt the solution lies somewhere with a join or something like that...
Erland Sommarskog
2015-01-19 22:19:28 UTC
Permalink
Post by m***@gmail.com
I have two tables, data and users
data holds account information, one field called midd which defines
ownership based on acctmin and acctmax fields in users
i want to pull data.* and users.*, but only limit it to where data.midd
is >= 0 and <= 33. when i'm trying to write my sql query, i'm getting
duplicates (becuase my results give more records than data has) and i've
no doubt the solution lies somewhere with a join or something like
that...
For this type of problem, it is often a good idea to post:

1) CREATE TABLE statements for your tables.
2) INSERT statements with sample data, enough to demonstrate the issue.
3) The desired result given the sample.
4) A short description of the business rules that explains why you want
that result.
5) Which version of SQL Server you are using.

I can't really comment on your problem, because I don't your tables. Or
your query.
--
Erland Sommarskog, Stockholm, ***@sommarskog.se
Continue reading on narkive:
Loading...