I have two tables in one database
customer table have customer coordinate infos
Customer type have infos about the type of customer
I want to have a destination table that has
destination customer table
key
name
adress
...
type
I did create a database vue of customer table + customer type but the result query only showed me the fields that have customer table key=customer table foreign key in customer type
and there are also fields in customer table that have no type.
How do I solve this issue
What kind of transformations did you use in your data flow task?
I rather do it on the SQL Server using INNER JOIN and something like SELECT INTO. If you want to join two tables on SSIS, use the Merge Join Transformation. However, the input for the Merge Join Transformation must be sorted so you can either use the Sort Transformation or just use ORDER BY when you get the data using OLE DB Source adaptors.
Hope this helps.
Related
I have one table
program(p_id(pk), program_name)
and three other tables:
graduate_survey(id(pk),PO1_avg,PO2_avg,program_name,session),
alumni_survey(id(pk),PO1_avg,PO2_avg,program_name,session),
faculty_survey(id(pk),PO1_avg,PO2_avg,program_name,session)...
I have to link the three tables with program table...How to link these tables in MySQL? graduate_survey, alumni_survey, faculty_survey are some forms which is calculated for some specific program...If in the forms graduate_survey, alumni_survey, faculty_survey there is no text box for entering the program_name, but if i made a column name 'program_name' in the database tables, can i enter the program_name by referencing to the program table? Is there will be any join query?
Use the program id as foreign key in the other tables, like so:
program(p_id(pk), program_name)
graduate_survey(id(pk),PO1_avg,PO2_avg,p_id(fk),session),
alumni_survey(id(pk),PO1_avg,PO2_avg,p_id(fk),session),
faculty_survey(id(pk),PO1_avg,PO2_avg,p_id(fk),session)
You don't really need the program name for the sake of the FK constraints but it's still a nice to have at some point, maybe.
This way you can easily join based on p_id, for instance:
"SELECT * FROM program INNER JOIN graduate_survey ON program.p_id=graduate_survey.p_id WHERE <your condition here>"
Hope this helps.
so I'm working on a datawarehouse project and I was given 3 csv files by my professor. The two I'm having trouble with are a mastersales file and a customer lookup. Both of these files share a column that is a CUST_ID I need to be able to insert or join the master sales file data with the customer dimension file based on the CUST_ID as a primary key. This is my first ever SQL project so I have literally no experience. My question would it be best to join the tables together based on the ID or to insert the master file data as well into the CUST_DIM and delete the columns that don't pertain to a customer? Thank you in advance
Best idea would be to use a JOIN for the CUST_ID with a method like:
SELECT CUST_DIM.CUST_BIRTH_DT, CUST_DIM.CUST_CITY_NM, CUST_DIM.CUST_STREET_ADD, CUST_DIM.CUST_POSTAL_CD, CUST_DIM.CUST_STATE_CD, CUST_DIM.CUST_NM, CUST_DIM.CUST_NO, CUST_DIM.CUST_PHONE_NO
FROM CUST_DIM
JOIN sales_filev1
ON CUST_DIM.CUST_NO=sales_filev1.**SALES ID NUMBER GOES HERE**
This would allow you to like both tables together and manipulate how you see fit.
I've a table with suppliers what has the following structure:
Pay attention to provider field. It's a VARCHAR now. I've got to support this system from another developer and now we need to have the list of providers and store additional info so I created another table for storing providers actually.
It has the following structure: id, name , margin, outer_name, etc.
I plan to change type of provider to INT(32) and it will point to provider table.
The problem is that MySQL doesn't support transactions for changing the structure of database.
If I changed type of field from string to integer I lose all previous data. IF something goes wrong in the middle. I'm lost.
Would it be ok dump data to file using serialisation and reading them from there?
Are there any better ways to do it?
Please follow the below steps to migrate data to new table and alter column.
1. Insert all data into new table (Provider Table)
INSERT INTO providerTable (NAME)
SELECT DISTINCT provider
FROM suppliers;
2. Update providerID into Main (Supplier) table
UPDATE suppliers s
INNER JOIN providerTable p ON s.provider = p.name
SET s.provider = p.id;
Before altering the table please verify your data into supplier table.
3. Then alter column datatype of Main (Supplier) table
ALTER TABLE suppliers CHANGE provider provider INT(4) NOT NULL
Using this approach you don't need to take backup of table. You won't loss any data.
I am creating a demo application. I am stuck in a scenario, I am not getting the exact way and query to fetch data from sql database in the following scenario:
I have a table named RegistrationTable, this table has a column RegistrationId as its primary key. There is another table named ApplicationDetails, this table has a column ApplicationId as its primary key.
I have referenced ApplicationId as Foreign key to RegistrationId column.
My requirement is, single user can apply to multiple jobs. job details will be present in ApplicationDetails table.
How can I check to how may jobs the user has applied based on his email id stored in registration table.
I have a column Status in ApplicationDetails table, where as soon as user applied to a job I am updating the status column.
I am trying the following query but its not working:
SELECT Status FROM ApplicationDetails
INNER JOIN RegistrationTable ON ApplicationTable.ApplicationId = RegistrationTable.RegistrationId
WHERE RegistrationTable.EmailId = "abc#xyz.com";
Can any one please suggest me how can I go about this. I am a beginner to SQL. Please do suggest a way to solve this. Thanks in advance.
You need to change the table name in your query to ApplicationDetails. This is what you mentioned in your post
SELECT Status FROM ApplicationDetails
JOIN RegistrationTable ON ApplicationDetails.ApplicationId = RegistrationTable.RegistrationId
WHERE RegistrationTable.EmailId = "abc#xyz.com";
I have an access table that has its own information as well as a subdatasheet that was linked to it using child/master fields. For each record in the table, there is one record in the subdatasheet. I was wondering if one can give me code for a query that would put all of this into one table.
If you are certain of the one-to-one relationship, then you can simply JOIN on the Foreign key relationship between the "Master" and "Child" tables:
SELECT m.PKID, m.MasterField1, m.MasterField2, c.ChildField1, c.ChildField2
FROM ChildTable AS c INNER JOIN MasterTable AS m ON c.ClientID = m.ClientID;
If you are really intending to merge these into a new table, then open the Access Query Editor, select SQL View from the View menu, and paste the above sample into the SQL view. Then swap your table names, and column names for those above (adding m.MasterField3, 4, . . . c.ChildField3, 4, etc . . .).
Then select Make Table Query from the Query type menu. Type a unique name for your new table, and Run the query.