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.
Related
Above is the Table "People"
Above is the SQL view of the Query "Count Country" based on Table "People"
Above is the datasheet view of the Query "Count Country" based on Table "People"
Above is another Table called "City List"
Why can't I create a one-to-many relationship between Query "Count Country" and Table "City List"?
What you describe sounds like cascading (dependent) comboboxes. So if you don't have a table of Countries, RowSource for cbxCountry can be SELECT DISTINCT Country FROM CityList;. Then RowSource for cbxCities filtered by cbxCountry SELECT City FROM CityList WHERE Country=[cbxCountry];. You will need code to requery cbxCity when moving to another record and/or when changing selection in cbxCountry.
If you want a form showing distinct country then RecordSource can be the same DISTINCT query. Then code to open a form for associated cities:
DoCmd.OpenForm "Cities", , , "Country='" & Me.Country & "'"
You can only create a relationship with referential integrity between tables. Also, both fields must have the same data type and the field(s) on the left (the field(s) that you draggeed to the other side) must be the primary key of that table (or at least have a unique index that does not allow for Null values).
The only reason for creating a relationship without referential integrity is to tell Access how the data is related, so Access will join both tables (or as in your case the table and the query) automatically when you add both of them to a query. Also, Access might automatically create a "subdatasheet" when dealing with datasheets.
To "automatically" build the form that jumps to the cities, use the form wizard and add fields from both your query and your table.
I'm new to MS access. I have a few tables. Table 'Learners' contains columns such as 'LearnerID' (unique), firstname, surname, status, etc. There's another table (LearnerUpdate) that I created by importing a spreadsheet. The LearnerUpdate also contains a learnerID and their names. I need to match the learner ID and update teh LearnerUpdate table to include the 'status' taken from the 'Learners' table. How do I do it?
I'm not even sure what to google for. The Access terminology is alien to me.
Thank you
Assuming the column you want to update in the LearnerUpdate table is named 'Status', then try to execute this SQL in the Queries table:
UPDATE LearnerUpdate
INNER JOIN Learners
ON LearnerUpdate.LearnerID = Learners.LearnerID
SET LearnerUpdate.Status = Learners.Status
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.
Here I am creating a view
CREATE VIEW customerusage
AS
SELECT group_concat(customername SEPARATOR ' ||| '),
customerlocation,
customerid,
product
FROM customer AS c
INNER JOIN product AS p ON (c.product_id = c.product_id)
GROUP BY product_id
This table is to be updated everyday, if it is done in every minute is too fine. How can I update it. Is any option other then view also fine to do.
You need to make your view updatable. See http://dev.mysql.com/doc/refman/5.6/en/view-updatability.html
In summary:
A view is updatable if there is a one-to-one relationship between the rows in the view and the rows in the base table that are going to be updated.
A view is insertable if it is updatable and the columns present in the base table but not named in the view have default values.
I think, the expression group_concat(customername SEPARATOR ' ||| ') will break the one-to-one relationship. I.e. this expression could prevent your view to be updatable.
The expression GROUP BY product_id will definitely break a one-to-one relationship between the view and the base table.
The other way around, when you update/insert on the base table, it will be reflected on the view depending one-to-one relationship. If there is such a relationship, the view will use a MERGE algorithm and modifications in the base table will be reflected in the view. If there is no such a one-to-one relationship the used algorithm will be TEMPLATE, that means, a temporary table will be created for the view. See http://dev.mysql.com/doc/refman/5.0/en/view-algorithms.html for view algorithms.
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.