Re: Matching fileds between two tables



It sounds like you'll want an outer join. Example:

SELECT T1.col1, T1.col2, T1.part_num, T2.col1, T2.col2
FROM Table1 AS T1
LEFT OUTER JOIN Table2 AS T2
ON T1.part_num = SUBSTRING(T2.large_col, 10, 5) ;

--
David Portas
SQL Server MVP
--

"Daniell" <Daniell@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E1187FC7-9EA8-4EEE-B142-ECFA9807991A@xxxxxxxxxxxxxxxx
>I hope I can explain this a little better. I have two tables that I need
> information from. The first table has all but two fields that I need. I
> am
> having two problems. First all I want to do is read the first table take
> the
> part number and check the second table. If it is not there I want print
> the
> information from the table and continue on reading the first table and if
> it
> is there I want to take the invoice and print it with the information from
> the first table. The second problem is the part number in the second
> table
> is part of a large field(132 bytes). It is always at the same postion 10
> bytes in the field


.



Relevant Pages

  • Re: Alternative to Not Exists
    ... In some circumstances you may improve performance by using an outer join but ... are logically equivalent if x is unique in B. ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL Syntax
    ... >> note that I've put the condition into the ON clause. ... >> of the LEFT OUTER JOIN will be logically treated as part of the join, ... >> SQL Server MVP ... >>> LEFT OUTER JOIN TableB etc. ...
    (microsoft.public.sqlserver.datamining)
  • Re: COUNT function not working with GROUP BY
    ... us more info, and maybe even some sample data and sample output, or at least ... SQL Server MVP ... > FROM Base_Contacts LEFT OUTER JOIN ... > syntax must be wrong because the ...
    (microsoft.public.sqlserver.server)
  • Re: Views
    ... >> You are issuing all your reads with NOLOCK hint. ... but data consistency is not guaranteed. ... >> Mike Epprecht, Microsoft SQL Server MVP ... >>> dbo.CQ.LInfoId RIGHT OUTER JOIN ...
    (microsoft.public.sqlserver.clients)
  • Re: Views
    ... > You are issuing all your reads with NOLOCK hint. ... but data consistency is not guaranteed. ... > Mike Epprecht, Microsoft SQL Server MVP ... >> dbo.CQ.LInfoId RIGHT OUTER JOIN ...
    (microsoft.public.sqlserver.clients)