English 中文(简体)
CCMSESS 2003 (2000年档案格式)
原标题:MS ACCESS 2003 (2000 file format) SQL query

i have a table with the fields : [VARIABLE_CODE],[VARIABLE_NAME],[CAS_NO],[USER_VAR_GROUP_NAME] and what i want to do to this talbe is to either use an append query and take entries from the table and put them into another table with the extra field [INDICATOR_NAME]. The [INDICATOR_NAME] varies accoridng to whats in the [VARIABLE_NAME]. Example AluminumDissovled variable name ---> Aluminum D Indicator name.

But the only way i can think of doing this is to have many append queries. one for each condition, each indictor name. and that would be very many queries to write. Is there anyway to have an append query that encompasses and will perform all the indicator nmes/conditions?

页: 1

add the extra field [INDICATOR_NAME] and run an update query liek the one below. [INDICATOR_NAME] will be added according to what is in the [VARIABLE_NAME] field. The problem is, i have ten differnt conditions below. but in reality i have about a hundred. from A-Z. Yet there is a limit to how many IFF you can have in a queries.
Is there anyway to have that many conditions in one query????

UPDATE QRY_Variables_A SET INDICATOR_NAME = 
IIf([VARIABLE_NAME]= ALUMINUM DISSOLVED (AL)  页: 1[VARIABLE_NAME]= ALUMINUM_27 DISSOLVED -       AL , Aluminum D ,
IIf([VARIABLE_NAME]= ALUMINUM TOTAL  页: 1[VARIABLE_NAME]= ALUMINUM TOTAL RECOVERABLE  页: 1        [VARIABLE_NAME]= ALUMINUM_27 TOTAL RECOVERABLE - AL , Aluminum T ,
IIf([VARIABLE_NAME]= ANTIMONY DISSOLVED (SB)  页: 1[VARIABLE_NAME]= ANTIMONY_121 DISSOLVED - SB , Antimony B ,
IIf([VARIABLE_NAME]= ANTIMONY TOTAL  页: 1[VARIABLE_NAME]= ANTIMONY TOTAL RECOVERABLE  页: 1[VARIABLE_NAME]= ANTIMONY_121 TOTAL RECOVERABLE - SB , Antimony T ,
IIf([VARIABLE_NAME]= ARSENIC DISSOLVED  页: 1[VARIABLE_NAME]= ARSENIC_75 DISSOLVED - AS , Arsenic D ,
IIf([VARIABLE_NAME]= ARSENIC TOTAL  页: 1[VARIABLE_NAME]= ARSENIC TOTAL RECOVERABLE  页: 1[VARIABLE_NAME]= ARSENIC_75 TOTAL RECOVERABLE - AS , Arsenic T ,
IIf([VARIABLE_NAME]= BARIUM DISSOLVED  页: 1[VARIABLE_NAME]= BARIUM_137 DISSOLVED - BA , Barium D ,
IIf([VARIABLE_NAME]= BARIUM TOTAL  页: 1[VARIABLE_NAME]= BARIUM TOTAL RECOVERABLE  页: 1[VARIABLE_NAME]= BARIUM_137 TOTAL RECOVERABLE - BA , Barium T ,
IIf([VARIABLE_NAME]= BERYLLIUM DISSOLVED  页: 1[VARIABLE_NAME]= BERYLLIUM_9 DISSOLVED - BE , Beryllium D ,
IIf([VARIABLE_NAME]= BERYLLIUM TOTAL  页: 1[VARIABLE_NAME]= BERYLLIUM TOTAL RECOVERABLE  页: 1[VARIABLE_NAME]= BERYLLIUM_9 TOTAL RECOVERABLE - BE , Beryllium T ,

))))))))));

谢谢大家的言辞、回答、时间、评论。

最佳回答

You might like to consider creating another table that holds the list:

Variable_Name                       Indicator_Name
ALUMINUM DISSOLVED (AL)             Aluminum D
ALUMINUM_27 DISSOLVED -       AL    Aluminum D

因此。 之后,你可以把这个表格列入你的主要表格,以获得指标名称:

SELECT MyTable.Variable_Name, NewTable.Indicator_Name 
FROM MyTable 
INNER JOIN NewTable
ON MyTable.Variable_Name = NewTable.Variable_Name

你甚至可能不需要更新该栏,但可以像现在这样安排,例如:

UPDATE MyTable 
INNER JOIN NewTable
On MyTable.Variable_Name = NewTable.Variable_Name
SET MyTable.Indicator_Name = NewTable.Indicator_name
问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签