473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

View Problem

I have created a view to test some of the data in my database. I am
relatively new to SQL so may have caused this problem by doing something
wrong.

I have a table called SYS_Individual which contains records on individuals.
A number of the fields in this take a numeric entry which corresponds to an
entry in another table (used to populate drop down menus in the application
being developed).

The tables which are used for the dropdowns are all related with one-to-many
to the Individual table.

However, when I run the View below, it returns only the records from the
SYS_Individual table where ALL the fields being referenced in other tables
are filled in - if a field is left empty, the whole record is not returned.

What might cause this, and how could I get around this?

I will post DDL for Table and Diagram if required.

Thank you
SELECT dbo.SYS_Individual.IND_First_Name AS [First Name],
dbo.SYS_Individual.IND_Surname AS Surname, dbo.SYS_DD_Age_Codes.AGE_Category
AS Age,
dbo.SYS_DD_Bank_Codes.BANKS_Institution,
dbo.SYS_DD_Business_Relationship_Codes.BUSRELAT_Ca tegory,
dbo.SYS_DD_Business_Type_Codes.BUSINESSTYPE_Type,
dbo.SYS_DD_Disadvantage_Codes.DIS_Category AS Disadvantage,
dbo.SYS_DD_Economic_Activity_Codes.ECONOMIC_Catego ry,
dbo.SYS_DD_Ethnicity_Codes.ETHNICITY_Category AS Ethnicity,
dbo.SYS_DD_Exit_Codes.EXIT_Category,
dbo.SYS_DD_Gender_Codes.GENDER_Category AS Gender,
dbo.SYS_DD_Growth_Potential_Codes.GROWTH_Potential AS
[Growth Potential],
dbo.SYS_DD_Marital_Status_Codes.MARITAL_Status AS
[Marital Status], dbo.SYS_DD_Referral_Source_Codes.REFERRAL_Source,

dbo.SYS_DD_Start_Up_Confirmation_Codes.STARTCONF_C ategory,
dbo.SYS_DD_Status_Codes.INDSTAT_Status,
dbo.SYS_DD_Training_Codes.TRAINING_Category
FROM dbo.SYS_DD_Age_Codes INNER JOIN
dbo.SYS_Individual ON dbo.SYS_DD_Age_Codes.AGE_ID =
dbo.SYS_Individual.IND_DD_Age_ID INNER JOIN
dbo.SYS_DD_Bank_Codes ON
dbo.SYS_Individual.IND_DD_Bank_ID = dbo.SYS_DD_Bank_Codes.BANKS_ID INNER
JOIN
dbo.SYS_DD_Business_Relationship_Codes ON
dbo.SYS_Individual.IND_DD_Business_Status_ID =
dbo.SYS_DD_Business_Relationship_Codes.BUSRELAT_ID INNER JOIN
dbo.SYS_DD_Business_Type_Codes ON
dbo.SYS_Individual.IND_DD_Potential_Business_Type_ ID =
dbo.SYS_DD_Business_Type_Codes.BUSINESSTYPE_ID INNER JOIN
dbo.SYS_DD_Disadvantage_Codes ON
dbo.SYS_Individual.IND_DD_Disadvantage_ID =
dbo.SYS_DD_Disadvantage_Codes.DIS_ID INNER JOIN
dbo.SYS_DD_Economic_Activity_Codes ON
dbo.SYS_Individual.IND_DD_Economic_Activity_ID =
dbo.SYS_DD_Economic_Activity_Codes.ECONOMIC_ID INNER JOIN
dbo.SYS_DD_Ethnicity_Codes ON
dbo.SYS_Individual.IND_DD_Ethnicity_ID =
dbo.SYS_DD_Ethnicity_Codes.ETHNICITY_ID INNER JOIN
dbo.SYS_DD_Exit_Codes ON
dbo.SYS_Individual.IND_DD_Exit_ID = dbo.SYS_DD_Exit_Codes.EXIT_ID INNER JOIN
dbo.SYS_DD_Gender_Codes ON
dbo.SYS_Individual.IND_DD_Gender_ID = dbo.SYS_DD_Gender_Codes.GENDER_ID
INNER JOIN
dbo.SYS_DD_Growth_Potential_Codes ON
dbo.SYS_Individual.IND_DD_Growth_Potential_ID =
dbo.SYS_DD_Growth_Potential_Codes.GROWTH_ID INNER JOIN
dbo.SYS_DD_Marital_Status_Codes ON
dbo.SYS_Individual.IND_DD_Marital_Status_ID =
dbo.SYS_DD_Marital_Status_Codes.MARITAL_ID INNER JOIN
dbo.SYS_DD_Referral_Source_Codes ON
dbo.SYS_Individual.IND_DD_Referal_Source_Code =
dbo.SYS_DD_Referral_Source_Codes.REFERRAL_ID INNER JOIN
dbo.SYS_DD_Start_Up_Confirmation_Codes ON
dbo.SYS_Individual.IND_DD_Start_Up_Confirmation_ID =
dbo.SYS_DD_Start_Up_Confirmation_Codes.STARTCONF_I D INNER JOIN
dbo.SYS_DD_Status_Codes ON
dbo.SYS_Individual.IND_DD_Status_ID = dbo.SYS_DD_Status_Codes.INDSTAT_ID
INNER JOIN
dbo.SYS_DD_Training_Codes ON
dbo.SYS_Individual.IND_DD_Training_Status_ID =
dbo.SYS_DD_Training_Codes.TRAINING_ID
Jul 20 '05 #1
1 1154
If you want rows even when not all columns referring other tables are not
NULL (or not filled in), you have to change (some of) your INNER JOINs to
LEFT OUTER JOINs.

--
Jacco Schalkwijk
SQL Server MVP
"Keith" <@.> wrote in message
news:Eo*********************@wards.force9.net...
I have created a view to test some of the data in my database. I am
relatively new to SQL so may have caused this problem by doing something
wrong.

I have a table called SYS_Individual which contains records on individuals. A number of the fields in this take a numeric entry which corresponds to an entry in another table (used to populate drop down menus in the application being developed).

The tables which are used for the dropdowns are all related with one-to-many to the Individual table.

However, when I run the View below, it returns only the records from the
SYS_Individual table where ALL the fields being referenced in other tables
are filled in - if a field is left empty, the whole record is not returned.
What might cause this, and how could I get around this?

I will post DDL for Table and Diagram if required.

Thank you
SELECT dbo.SYS_Individual.IND_First_Name AS [First Name],
dbo.SYS_Individual.IND_Surname AS Surname, dbo.SYS_DD_Age_Codes.AGE_Category AS Age,
dbo.SYS_DD_Bank_Codes.BANKS_Institution,
dbo.SYS_DD_Business_Relationship_Codes.BUSRELAT_Ca tegory,
dbo.SYS_DD_Business_Type_Codes.BUSINESSTYPE_Type,
dbo.SYS_DD_Disadvantage_Codes.DIS_Category AS Disadvantage,
dbo.SYS_DD_Economic_Activity_Codes.ECONOMIC_Catego ry, dbo.SYS_DD_Ethnicity_Codes.ETHNICITY_Category AS Ethnicity,
dbo.SYS_DD_Exit_Codes.EXIT_Category,
dbo.SYS_DD_Gender_Codes.GENDER_Category AS Gender,
dbo.SYS_DD_Growth_Potential_Codes.GROWTH_Potential AS [Growth Potential],
dbo.SYS_DD_Marital_Status_Codes.MARITAL_Status AS
[Marital Status], dbo.SYS_DD_Referral_Source_Codes.REFERRAL_Source,

dbo.SYS_DD_Start_Up_Confirmation_Codes.STARTCONF_C ategory,
dbo.SYS_DD_Status_Codes.INDSTAT_Status,
dbo.SYS_DD_Training_Codes.TRAINING_Category
FROM dbo.SYS_DD_Age_Codes INNER JOIN
dbo.SYS_Individual ON dbo.SYS_DD_Age_Codes.AGE_ID =
dbo.SYS_Individual.IND_DD_Age_ID INNER JOIN
dbo.SYS_DD_Bank_Codes ON
dbo.SYS_Individual.IND_DD_Bank_ID = dbo.SYS_DD_Bank_Codes.BANKS_ID INNER
JOIN
dbo.SYS_DD_Business_Relationship_Codes ON
dbo.SYS_Individual.IND_DD_Business_Status_ID =
dbo.SYS_DD_Business_Relationship_Codes.BUSRELAT_ID INNER JOIN
dbo.SYS_DD_Business_Type_Codes ON
dbo.SYS_Individual.IND_DD_Potential_Business_Type_ ID = dbo.SYS_DD_Business_Type_Codes.BUSINESSTYPE_ID INNER JOIN
dbo.SYS_DD_Disadvantage_Codes ON
dbo.SYS_Individual.IND_DD_Disadvantage_ID =
dbo.SYS_DD_Disadvantage_Codes.DIS_ID INNER JOIN
dbo.SYS_DD_Economic_Activity_Codes ON
dbo.SYS_Individual.IND_DD_Economic_Activity_ID =
dbo.SYS_DD_Economic_Activity_Codes.ECONOMIC_ID INNER JOIN
dbo.SYS_DD_Ethnicity_Codes ON
dbo.SYS_Individual.IND_DD_Ethnicity_ID =
dbo.SYS_DD_Ethnicity_Codes.ETHNICITY_ID INNER JOIN
dbo.SYS_DD_Exit_Codes ON
dbo.SYS_Individual.IND_DD_Exit_ID = dbo.SYS_DD_Exit_Codes.EXIT_ID INNER JOIN dbo.SYS_DD_Gender_Codes ON
dbo.SYS_Individual.IND_DD_Gender_ID = dbo.SYS_DD_Gender_Codes.GENDER_ID
INNER JOIN
dbo.SYS_DD_Growth_Potential_Codes ON
dbo.SYS_Individual.IND_DD_Growth_Potential_ID =
dbo.SYS_DD_Growth_Potential_Codes.GROWTH_ID INNER JOIN
dbo.SYS_DD_Marital_Status_Codes ON
dbo.SYS_Individual.IND_DD_Marital_Status_ID =
dbo.SYS_DD_Marital_Status_Codes.MARITAL_ID INNER JOIN
dbo.SYS_DD_Referral_Source_Codes ON
dbo.SYS_Individual.IND_DD_Referal_Source_Code =
dbo.SYS_DD_Referral_Source_Codes.REFERRAL_ID INNER JOIN
dbo.SYS_DD_Start_Up_Confirmation_Codes ON
dbo.SYS_Individual.IND_DD_Start_Up_Confirmation_ID =
dbo.SYS_DD_Start_Up_Confirmation_Codes.STARTCONF_I D INNER JOIN
dbo.SYS_DD_Status_Codes ON
dbo.SYS_Individual.IND_DD_Status_ID = dbo.SYS_DD_Status_Codes.INDSTAT_ID
INNER JOIN
dbo.SYS_DD_Training_Codes ON
dbo.SYS_Individual.IND_DD_Training_Status_ID =
dbo.SYS_DD_Training_Codes.TRAINING_ID

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ryan | last post by:
Bit of an obscure one here, so please bear with me. I have two copies of a database which should be identical. Both have a complex view which is identical. I can open the views and the data is as...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
4
by: stacdab | last post by:
We have a partitioned view with 4 underlying tables. The view and each of the underlying tables are in seperate databases on the same server. Inserts and deletes on the view work fine. We then...
20
by: Neil | last post by:
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table with 50,000 records; and I have a selections table with 50,000 records for each machine that uses the database (about...
3
by: bughunter | last post by:
I discover next problem I have view definition with rank() create view vTEST as select c1, c2, c3, ... -- problem area start , rank() over (order by c3) as RNK -- problem area stop from...
2
by: Brad | last post by:
I have an intranet app that has just started sporadically getting the following error "The viewstate is invalid for this page and might be corrupted." By sproadic I mean 3-4 times during the past...
12
by: Raed Sawalha | last post by:
I have the following table which i can not switcha to design view error message said Could not open in Design view. Quote values differently inside a '<% ...."value"... %>' block. and the...
5
by: Sim Zacks | last post by:
I just did a dump and restore of my database and one of my views did not recreate. The error received was : pg_restore.exe: could not execute query: ERROR: column reference "pricinggroupid" is...
1
by: Nogusta123 | last post by:
Hi, I have had a lot of problems getting web pages, master pages and content pages to render in VS2005 design view the same as they would in Internet Explorer. I did a lot of looking on the...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.