I am learning vb.net and ms sql (2000 evaluation version); I can't get my joins to work in Tsql:
select m.lname,m.fname,m.idno,m.payorno,p.payorno.p.payor name
from dbtemp..d_mbrdata m join dbtemp..d_payors p
on (m.payorno = p.payorno)
inner join query returns no records at all. left outerjoin returns the mbrdata fields, but the payors fields show as null. payorno in both tables is type integer and both tables definitely have matching records. I created index for both tables on payorno.
Does anyone have an idea what i am doing wrong here? Thanks.There is nothing wrong with query. If left join returns some data - problem is in second table (matching records).
Just run this query (without join):
select *
from dbtemp..d_mbrdata
where payorno in (select distinct payorno from dbtemp..d_payors)|||Yeah, from the way u'r describing u'r results, it seems there is no m.payorno that is equal to p.payorno.
Maybe u can try debuggin further by inserting a new record into both this tables with a "confirm" identical payorno and do your select join statement again.
It should return 1 joined record.|||Try running this and see what key values are returned:
select m.payorno, p.payorno
from dbtemp..d_mbrdata m
full outer join dbtemp..d_payors p on (m.payorno = p.payorno)
where mpayrono is null or p.payorno is null
blindman
Showing posts with label joins. Show all posts
Showing posts with label joins. Show all posts
Monday, March 12, 2012
Newbie help with joins
Wednesday, March 7, 2012
Newbie : Efficiency question - performance
Hi,
querying through SQL, wich gives the best result
having to look in to a large table, or looking in smaller tables but with a
lot of joins...
I'm asking this because right now, i have in my design a couple of tables
with only two or three columns, and about 10 records in each.
Would it be more interesting to add these values in my first table, and
create more records in it..Boonaap wrote:
> Hi,
> querying through SQL, wich gives the best result
> having to look in to a large table, or looking in smaller tables but
> with a lot of joins...
> I'm asking this because right now, i have in my design a couple of
> tables with only two or three columns, and about 10 records in each.
> Would it be more interesting to add these values in my first table,
> and create more records in it..
In general, you should use a relational design and only resort to
denormalization if absolutely necessary for performance. So for now I
would suggest you stick to the relational design you have and tune the
query as needed with properly designed indexes. 10 rows of data is so
small that you probably wouldn't have much of a performance issue.
David Gugick
Imceda Software
www.imceda.com|||>> Would it be more interesting to add these values in my first table, and
The number of columns in a table and the number of tables in a database are
not valid criteria for determining good designs. You may want to start by
analyzing the business model and understand the data requirements first
rather than being concerned about performance of a special query with "lots
of joins".
In general, the number of columns in a table and the number of tables in a
schema by themselves are no way related to performance. However, it may be
worthwhile to keep in mind the limitations of the DBMS, its physical
optimization variables etc which can have an effect on the performance on
some queries.
Anith
querying through SQL, wich gives the best result
having to look in to a large table, or looking in smaller tables but with a
lot of joins...
I'm asking this because right now, i have in my design a couple of tables
with only two or three columns, and about 10 records in each.
Would it be more interesting to add these values in my first table, and
create more records in it..Boonaap wrote:
> Hi,
> querying through SQL, wich gives the best result
> having to look in to a large table, or looking in smaller tables but
> with a lot of joins...
> I'm asking this because right now, i have in my design a couple of
> tables with only two or three columns, and about 10 records in each.
> Would it be more interesting to add these values in my first table,
> and create more records in it..
In general, you should use a relational design and only resort to
denormalization if absolutely necessary for performance. So for now I
would suggest you stick to the relational design you have and tune the
query as needed with properly designed indexes. 10 rows of data is so
small that you probably wouldn't have much of a performance issue.
David Gugick
Imceda Software
www.imceda.com|||>> Would it be more interesting to add these values in my first table, and
The number of columns in a table and the number of tables in a database are
not valid criteria for determining good designs. You may want to start by
analyzing the business model and understand the data requirements first
rather than being concerned about performance of a special query with "lots
of joins".
In general, the number of columns in a table and the number of tables in a
schema by themselves are no way related to performance. However, it may be
worthwhile to keep in mind the limitations of the DBMS, its physical
optimization variables etc which can have an effect on the performance on
some queries.
Anith
Labels:
database,
efficiency,
joins,
microsoft,
mysql,
newbie,
oracle,
performance,
querying,
resulthaving,
server,
sql,
table,
tables,
wich
Subscribe to:
Posts (Atom)