Creating columns in table by using records of another table - dynamic-columns

I want to create table B in database, table B will contain columns same as the records of particular column in Table A. Means I have to create Table B with columns same as records in Table A. How to do this? Suggestions please? This is the desired table from which i want to copy records of one column and add to another table as columns

Related

Access Update Query - Only update fields in table if source field is not null

I have an update query set up like this
Table A = Table to be updated
Table B = Table to be used as the source table to update table A
I am wanting to use Table B as sort of an Autofill table. The user would enter values into the fields in Table B. After running the update query, all fields in Table A would be updated to the values in Table B.
So far it works and updates all fields as intended. This is to update mass amounts of records which need the same data in those fields. My issue is that say I only want to update field1 in Table A. If I only enter a value in field1 of Table B, then the update query will update not just that field, but it will also update all values in all the other fields as blank. How can I prevent this from overwriting those other fields? If I put a criteria that the source field be "is not null" it wont run any update if even one field is left blank in Table B.
Im comfortable working with VBA but im not sure how I to even start for this kinda of update.
Id appreciate any help!
-Mario

Join tables in Spotfire in a third new table

I have two data tables tab1 and tab2 that I want to join.
I know how to do it with the insert columns property, however it is not what i really need. I want the result to be stored in a third new table tab3.
Add new data table, add from current analysis (scroll down). Select table 1. Name it table 3. Now insert columns to table 3 from table 2. At the end of this you will have 3 tables.
you can Add New Data Table From... Current Analysis>>[your existing data table] to create a reference or "virtual" table. any structural changes made to your referenced (original) table will propogate to the referenced (new) one.

Rails where two tables have the same data?

I'm trying to create a table in my view and populate it on some conditions.
I have two tables, Both have two columns inside, One columns called event_url and the other is gmiurl. The table with gmiurl inside is called GMITable and the other is called newevent
Basically i want to show everything inside the GMITable unless the column event_url has a url inside that matches to any of the urls inside gmiurls inside the GMITable
I dont have anycode for this apart from this at the moment
#GMI = GMITable.all
You can easily achieve the result by using a LEFT OUTER JOIN from Table A to Table B, as described in this visual explanation.
Specifically, what you want is:
To produce the set of records only in Table A, but not in Table B, we perform the same left outer join, then exclude the records we don't want from the right side via a where clause.
In your question is not clear how the tables are called, and how they relate each other. However, to achieve the result simply perform a join between the tables using the ActiveRecord join method
TableA.joins('LEFT OUTER JOIN TableB on TableA.field = TableB.field')
and select only the items where(TableB.id IS NULL).
You'll have to adapt the example to your needs.

Nested Result set(Child and Parent) on same table

I'm using Entity framework to bring in the data to a mvc application.
The table contains 2 columns, One column contains the IDs(string) and other contains SQL Queries(string). I want to bring the data to a grid which will have 3 columns i.e. ID, Query and the result of that Query.My plan of approach was to bring the 2 columns in though a parent result set and get the result of the queries in a child result set and display them on the grid. How to I approach this?

DB grid : How to use a column of the current row of one as an index into another?

I am not sure if the question title is clear enough, please feel free to edit it.
Basically, I have two DB grids which reflect two database tables, each grid showing one.
When the user selects a row in the first table (let's call it oders), I want to update the second with details of any rows matching a column of the selected row of the first table.
Say, for instance that table orders has a column customer_id and I want to populate the second table (let's call it order_details) with details of all orders from that customer, one order per row.
I can connect up 2 # datasource, query and connection to the two TDbGrids, but I am stuck as to how to code order_details SQL.
The SQL for orders is just SELECT * from orders, but the other?
I want something like SELECT * from order_details WHERE cutomer_id=<orderQuery>.currentRow.FieldByName("customer_id").AsInteger - but I don't know how to do that ...
Can someone help me with some Delphi code?
Also, once I set up that relationship, will selecting a new row in the orders DB grid automatically update the order_details DB grid? Or do I need to add code for that.
P.s I know that there is no books tag anymore (more's the pity), but can someone recommend a good book which explains the fundamentals of programming DB aware controls? I obviously need one. Thanks
Use a parameterized query for the detail (child) database:
SELECT * FROM Order_Details od WHERE od.CustomerID = :CustomerID
Then set the child query's MasterSource to the parent (Order) datasource, and the MasterFields to CustomerID. (If there are multiple columns that link the two, separate them by ;, as in CustomerID;OrderNumber.)
Every time you scroll the parent (change the selected record in the parent DBGrid), the child query will be executed with the ID of the parent row passed as a parameter automatically.

Resources