Selecting all data from employee where foreign key = null and show it in view

Hi guys i have view like following :
SELECT dbo.Nationality.NationalityName, dbo.Employee.DriverName, dbo.Employee.DriverID, dbo.Employee.NationalityID, dbo.Employee.ResidentNo,
dbo.Country.CountryName, dbo.Employee.CountryID, dbo.Branch.BranchName, dbo.Employee.BranchID, dbo.Employee.JoinDate,
dbo.Employee.ResignDate, dbo.Employee.HealthCarNo, dbo.Employee.JobID, dbo.Jobs.JobName, dbo.Department.DepartmentName,
dbo.Jobs.DepartmentID, dbo.Employee.PlaceIssue, dbo.Employee.Deduction, dbo.Employee.ExpireDateMedical, dbo.Employee.PolicyNumber,
dbo.Employee.Owner, dbo.Employee.Version, dbo.Employee.ExpireDateResident, dbo.Employee.Salary, dbo.Employee.SexID, dbo.Sex.SexType,
dbo.Sex.FlagSex, dbo.Employee.MiritialID, dbo.Miritial.MiritualStatus, dbo.Status.StatusType, dbo.Employee.StatusID, dbo.Employee.UnactiveReason,
dbo.Employee.BirthDate, dbo.Employee.DateToday, dbo.Employee.UserID, dbo.Employee.PassportNo, dbo.Employee.Period,
dbo.Employee.AccountNo, dbo.Employee.Bonus, dbo.Employee.AccountType, dbo.Employee.PlaceOfBirth, dbo.Employee.EmplyeeName,
dbo.Employee.ExpireDateresidentHijri, dbo.Employee.PassportDateStart, dbo.Employee.PassportDateExpire, dbo.Religon.ReligonName,
dbo.Employee.ReligonID
FROM dbo.Nationality INNER JOIN
dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID INNER JOIN
dbo.Country ON dbo.Employee.CountryID = dbo.Country.CountryID INNER JOIN
dbo.Branch ON dbo.Employee.BranchID = dbo.Branch.BranchID INNER JOIN
dbo.Jobs ON dbo.Employee.JobID = dbo.Jobs.JobID INNER JOIN
dbo.Department ON dbo.Jobs.DepartmentID = dbo.Department.DepartmentID INNER JOIN
dbo.Sex ON dbo.Employee.SexID = dbo.Sex.SexID INNER JOIN
dbo.Miritial ON dbo.Employee.MiritialID = dbo.Miritial.MiritialID INNER JOIN
dbo.Status ON dbo.Employee.StatusID = dbo.Status.StatusID INNER JOIN
dbo.Religon ON dbo.Employee.ReligonID = dbo.Religon.ReligonID
suppose i need to show all data from Employee table (NationalityName,BranchName,JobName) where
NationalityID =NULL OR BranchID=NULL OR JobID=NULL
WHAT I DO
Notes : I mean in topic(selecting all data from view not table
meaning i need to show all data in employee table by view
in case of forign key(any forign key)equal null

I think you need to change 
FROM dbo.Nationality INNER JOIN
dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
to
FROM dbo.Nationality
LEFT JOIN
dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Database Adapter: Selecting all data from table

    Hi All
    I am new to SOA Suite and I am using Soa Suite version 10.1.3.1 and Jdev version 10.1.3.3. It is required to select data from one database using the database adapter and insert it in a table in another database. I implemented the flow using DBadapters select operation the problem is everytime I am running the instance it transfers only one row though no condition has been specified on the select. Could anyone please help me out and let me know how to transfer a complete table from one database to another using DBadapters and in a single instance.
    Thanks

    Well Stupid me, got the answer, I think m just at the begining of the learning curve.

  • I created folders in iphoto on my imac, synch using itunes and selected all photos from iphoto but those albums don't show up...most my albums do but a few don't!??

    I have a new iMac and I'm a new mac user....I have an iphone5..and ipad2.
    I have created folders on the imac in iphoto.
    I am synching the ipad and iphone with mac using itunes...selecting all photos, 3,500+ and although all the pictures may be sharing on all devices, the folders aren't.
    I have created several folders and copied pictures into those folders and they look fine while in iphoto....but I can't get the to synch into ipad and iphone using itunes.

    Folders in iPhoto do not contain photos. Albums and Events do. Folders can contain albums, but not photos on their own.
    So, do you mean Albums?

  • Select data from table where field is initial

    I have table that has 10 million records.
    I want to select data from this table where certain date field is blank.
    *SELECT * FROM table*
    INTO TABLE internal table
    WHERE PSTNG_DATE = BLANK.
    Does anybody know how to select data from data base table when certain field is blank.
    I cont select all data once and delete which i dont want, the table is big, it will blow up app server.
    thanks in advance,
    Sachin
    Moderator: Pls do not lock the posting instead provide me the link, its disrespecting.

    Respect the forum rules and common sense, and you will be respected.
    "how to select data from a database table when the field is blank" is very basic, and basic questions will be locked, because they have been asked many times and you can find the answer yourself with a little effort. There is nothing disrespectful about it.
    Thread locked.
    Thomas

  • How can use the select statement  to retriev the data from  a where conditi

    Hi,
    SELECT KUNNR
               NAME1
               STRAS
               ORT01
               PSTLZ
               LAND1
         FROM  KNA1
         INTO TABLE IT_KNA1
         FOR ALL ENTRIES IN IT_LIKP
         WHERE KUNNR = IT_LIKP-KUNNR AND
               KUNNR = IT_LIKP-KUNAG.
    Here I am getting records only when WHERE KUNNR = IT_LIKP-KUNNR AND
                                            KUNNR = IT_LIKP-KUNAG.
    But I need the records for both when KUNNR = IT_LIKP-KUNNR
                                 And     KUNNR = IT_LIKP-KUNAG.
    Can you suggest me the best logic.
    Thanks.
    Kumar .

    Hi Suresh,
    Use the following code.
    Loop at it_likp.
    if it_likp-kunnr <> ' '.
    select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
             from kna1
             where kunnr = IT_LIKP-KUNNR.
    elseif it_likp-kunag <> ' '.
    select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
             from kna1
             where kunnr = IT_LIKP-KUNAG.
    elseif it_likp-kunnr <> ' ' and it_likp-kunag <> ' '.
    select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
             from kna1
             where kunnr = IT_LIKP-KUNNR
             AND   KUNAR = IT_LIKP-KUNAG.
    endif.
    endloop.
    hOPE THIS WILL WORK FINE.
    Rewards pts if it is usefull.
    Regards
    Srimanta

  • How can i delete all data from treo 750 - where is the hard reset button for the treo 750

    I'm giving my phone to my brother and want to delete all my data from the treo 750 (AT&T).  All the other posts I read doesn't tell me where the reset button is.  Please Help!
    Post relates to: Treo 750 (AT&T)

    Hello and welcome to the Palm forums.
    A hard reset wipes everything off your device. A hard reset is performed by holding down the power/end call button while removing the battery from your device for a few seconds. Keep your hand on the power/end call button until you put the battery back into your device. After you put the battery back in, the screen will say "Palm Powered." Take your hand off the power/end call button. You will now see a screen in 5 languages prompting you to erase all data from the palm. The screen will say "erase all data? Yes - up, no - down" and you need to click on the up arrow (button on the 5 way navigator on the bottom of the treo). This will erase all the info from your device.
    I hope this was helpful!
    Post relates to: None

  • I have a new Macbook Pro. All data from prior Mac was migrated to new Mac. If I run Time Machine and "inherit" the old backups will TM take up where I left off, or delete and overwrite the current data?

    I have a new Macbook Pro. All data from prior Mac was migrated to the new Mac. I want to continue Time Machine on the new Mac and retain the history. An option is to "inherit" the old Time Machine. I want to make sure this does not errase the current data, but creates a current backup.

    Please visit Pondini's Time Machine FAQ for help with all things Time Machine.

  • To Select the data from two table one is transp table and onther is cluster

    Hi All,
    I want to select the data from two tables
    Here i am giving with an example.
    Fileds: kunnr belnr from bseg.  table bseg
    fields: adrnr from kna1     table: kna1.
    Know i want to put these into one internal table based on kunnr and belnr.
    Thanks in advance.
    Ramesh

    Hi,
       U cant use joins on cluster table and BSEG is a cluster table so use FOR  ALL ENTRIES for taht
    refer this code
    *&      Form  sub_read_bsak
          text
    -->  p1        text
    <--  p2        text
    FORM sub_read_bsak.
    *--Select data from BSAK Table
      SELECT lifnr
             augdt
             augbl
             gjahr
             belnr
             xblnr
             blart
             dmbtr
             mwskz
             mwsts
             sgtxt
             FROM bsak
             INTO CORRESPONDING FIELDS OF TABLE it_bsak
             WHERE belnr IN s_belnr
             AND   augdt IN s_augdt.
      IF sy-subrc EQ 0.
    *--Sort table by accounting document and vendor number
        SORT it_bsak BY belnr lifnr.
      ENDIF.
    ENDFORM.                    " sub_read_bsak
    *&      Form  sub_read_bseg
          text
    -->  p1        text
    <--  p2        text
    FORM sub_read_bseg.
      IF NOT it_bsak[] IS INITIAL.
    *--Select data from BSEG table
        SELECT belnr
               gjahr
               shkzg
               kostl
               hkont
               ebeln
               ebelp
               FROM bseg
               INTO CORRESPONDING FIELDS OF TABLE it_bseg
               FOR ALL ENTRIES IN it_bsak
               WHERE belnr EQ it_bsak-belnr
               AND   gjahr EQ it_bsak-gjahr
               AND   shkzg EQ 'S'.
        IF sy-subrc EQ 0.
    *--Sort table by accounting document
          SORT it_bseg BY belnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " sub_read_bseg

  • How to achieve that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND n"

    How to achieve the SQL like that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND name = 'Will' " with BDB C-API
    The primary key in the primary database is 'age' ,and the secondary key in the secondary index is 'name' ,in a lot of examples ,there are all simple , but how to do that complex one.thx~

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • How to select all PERNR from infotype 0000 (Action)

    Hi,
    How to select all PERNR from IT0000 (Action), if an action has been done on IT0000 between reporting START DATE and END DATE. What fields I should consider in IT0000.
    Thanks,
    mini

    You can try:
    data: t_0000 type standard table of pa0000.
    select * from pa0000
       into corresponding fields of table t_0000
      where begda le <your-initial-date> and endda ge <your-final-date>.
    Or use one of options described at last forum.
    Regards!
    Marcello
    Edited by: Marcello Lanzoni on Jul 24, 2008 8:11 PM

  • Fetching all data from MS access PROBLEM !!!

    Hi all,
    I am having problem of fetching all data from MS ACCESS, ie, I have 112 rows of data, yet when executing query SELECT * ... only 70 items are retrieved. Don't know why, but the retrieval prcess stops on item 69 and want get the rest of the data.
    I am executing the query in a WHILE loop, don't specify the number of loops !!! so I should be able to get all of the data. Why then I always only get 69?
    Second q.
    What is the right SYNTAX for retrieving specific data. ie. SELECT id from images WHERE size = 58
    is this correct? ie. size is declared as number?
    ANy help would be much appreciated.
    Thanks

    1. Where from you are fetching the data? Is it from bean or JSP or servlet? Can you post the code?
    2. Yes. the sql syntax is correct.

  • How to select the data from a Maintainance View into an internal table

    Hi All,
    Can anybody tell me how to select the data from a Maintainance View into an internal table.
    Thanks,
    srinivas.

    HI,
    You can not retrieve data from A mentenance view.
    For detail check this link,
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
    Regards,
    Anirban

  • How do I transfer all data from my old internal hard drive to a new internal hard drive

    How do I transfer all data from my old internal hard drive to a new internal hard drive? I have an iMac with a 320gb internal HD that is full and I am replacing it with a 2tb internal drive. I have several external drives; 1 tb, 2tb and 3 tb. The 2 tb is being used for Time Machine. Do I have to buy an enclosure? If so, where would I get an inexpensive one?
    I also want to partition the new internal drive for Windows, and I'm not sure how much space to use for that. I plan to use Windows to check my work in PowerPoint created on my Mac for clients on PCs.

    Do you already have Time Machine making backups onto the 2TB drive? If so, after you get the internal drive replaced, boot up into the recovery partition (hold down ⌘R) and restore the latest Time Machine backup that you have onto the new internal drive.
    I recommend always having two backups. I'd use SuperDuper to make a complete clone of your internal drive onto an external drive in addition to having the Time Machine backup.
    Boot Camp is what is used to make partitions for Windows. How much space to allocate depends on how much space you expect Windows to use up based on how you plan to use it.

  • SQL Developer Data Modeler not drawing foreign key relationships

    I'm having trouble with SQL Developer Data Modeler when I importa a DDL that has foreign keys. I export DDL files from SQL developer and choose various subsets of files. Sometimes Data Modeler will not recognize a foreign key if I include say a dozen files in the DDL file, but it will if I include just a few. Worse, even if the foreign key is recognized, sometimes it is not drawn in the Data Modeler and I have no way to make it be drawn. To be specific, I import a file containing the DDL for just two tables -- I see the foreign key! I import a file containing the DDL for a dozen tables including the two, I don't! Is there something I am not understanding about when Data Modeler will draw foreign keys or is the tool simply quite buggy?
    Much thanks!
    -ttamon

    Hi Philip,
    I believe I have isolated the problem. Apparently if a field is named "FOREIGN..." it interferes with the tool recognizing foreign keys. Try to import a DDL file containing the following text:
    CREATE TABLE "SAMPLE"."SAMPLE_ONE"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "VALUE" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ;
    CREATE TABLE "SAMPLE"."SAMPLE_TWO"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "FOREIGN_NAME" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ;
    CREATE TABLE "SAMPLE"."SAMPLE_THREE"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "VALUE" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "ALT_ID" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ENABLE,
         CONSTRAINT "FK6DF8294F2288190D" FOREIGN KEY ("ALT_ID")
         REFERENCES "SAMPLE"."SAMPLE_ONE" ("ID") ENABLE
    TABLESPACE "SAMPLE_DATA" ;
    You will discover the foreign key is not recognized or drawn! Now, if you swap the location of the third table (put it up first) everything works fine. This is how I discovered the problem, various subsets would work, others would not. To confirm the problem is with the field named "FOREIGN_NAME" use the DDL as specified above but change the first letter in the word "FOREIGN" to something else, and it will recognize the foreign key. Looks like a bug to me (took me about 4 hours to isolate this!). I am using Oracle SQL Developer Data Modeler version 2.0.0 Build 584.
    -ttamon

  • I lost all data from cell and sd card suddenly even I paused updates and on mobile data service.

    I hv lost my all data from my BlackBerry suddenly it's totally washed out,i shared my device code and pins wid frend living afar,mostly I got his screen msgs remotly,i just can't understand where my data gone n how can I get back it,its not coming wid restore settings

    @sonaprachi
    Welcome to the forum!
    If you mean PC Suite and not Ovi Suite you might like to look at NbuExplorer here:http://sourceforge.net/projects/nbuexplorer/
    In hindsight it is unfortunate that you did not go to Menu > Office > File mgr. > Memory card > Options > Backup phone memory (to memory card) prior to reset and after format of memory card!
    Happy to have helped forum with a Support Ratio = 42.5

Maybe you are looking for