Posted: 12/29/2011 11:35:41 AM EDT
|
When it comes to running a query in access I know the headers are supposed to be the same to get the same results if you want to use that query again on other data. Say you have one set data that will be used every time you run this query and different data each time you want to run. Without changing the layout of the header or renaming the headers to match the previous run data. Could you write a script in SQL that says "if the header kind of matches this header title % then pull that data in that column. Then if there other fields with data add that to the output table, that way you don't loose data from that file when it excicutes the query putting the data into the new table.
For example: You are santa and you are keeping a record of Christmas gifts being sent to kids. You have a naughty list that that you want to run table 1 against and get a new table with the naughty people off of it. You want the new table to have all the "good kids" then you have the rest of the data on the gifts to be given to you in that query result. But sometimes your "good kid list" isn't the same because Mrs clause might make the ones for north America, an elf for europ and a for australia. So they may use different headers and you don't want to manually run the query each time. Especially if you Can just upload the files they gave you. What says the tech hive, can this be done? |
|
You are confusing output views with the tables.
Tables are made up of records, records have fields, fields have names and data types. Your query looks something like this: SELECT field_a, field_b, field_c FROM table_a INNER JOIN table_b ON ... WHERE field_a = "..." ORDER BY field_b For this query to work on multiple tables, each field referenced in the query needs to exist by that exact name is each table. (I am not sure if this is exactly what you are asking.) If you want the output of the multiple queries on the multiple tables to be used as generic input to other things, the output columns' names and data types need to match in each of the queries. The data types are a little harder to fudge if they don't match, but the CAST and CONVERT functions (does Access have those?) can help. To get the output column names to match in each query, it is as simple as giving each column a specific name in the SELECT statement. For example: SELECT field_a AS 'FirstName', field_b AS 'LastName' FROM ... |
|
I know that it is supposed to be the exact same, but I'm trying to see if there is a way where you have have a "Like" Statement in the program and have it be like "name" but could be name1 or fullname etc...
I know that its supposed to be 100 for a query to work properly, but like I said I'm trying to see if an SQL line of syntax could fix this. I don't have much knowledge with SQL but just playing around with it. |
|
If it is the output that you need to be the same, then this is quite easy. Use the AS clause on the fields to rename them in the output. Save each of these queries either separately so that you can just run them as needed, or put the query into each db file that each "user" is using.
You are still a little fuzzy on the problem you are trying to solve. |