Tuesday 15 April 2014

sql - One select on two tables with NULL and not null -


I try to select from two tables and use some data from each other using WHERE (PL / SQL)

I have those two tables:

table1

  ID name color COMPANY_SHORT_NR 1 a green 1 2b red 23 3c blue Null 4 A Green Faucet 5G Green 1   

Table 2

  ID Small Comp_NAME 1 1 Company_Name 2 23 comapny_name_2   < P> And now I get all the data from table 1 in the name of companies and If it gets its free information then it is null like that  
  1 green company_name_1 2b redcomp__de_2 3c blue tap 4 green rickel 5g I tried to do this:  
  ID, NAME, COLOR, Table 1, Table 2, where COMPANY_SHORT_NR = SHORT     

from the COMPANY_SHORT_NR, but it only gives me blank values Do not give:

  1 green company_name_1 2b red comapny_name_2 5g green company_name_1   

If I use sth like this: < Previous> ID, name, Select the number, COMPANY_SHORT_NR from Table 1, Table 2 where COMPANY_SHORT_NR = SHORT or COMPANY_SHORT_NR is zero

I get the thousends of the record ... if I only IS Null I just need 2 rows, as it should be.

Where do I make a mistake?

You can join an oyar for that

  Select, COLOR, COMPANY_SHORT_NR from Table 1 to the left OUTER table 2 (COMPANY_SHORT_NR = SHORT)    

No comments:

Post a Comment