English 中文(简体)
反变数
原标题:Counter variable in SQLite

I m每周工作一次,每小时工作一栏。 在启动时,评估检查了从现在起是否有任何不完整的任务。 如果是的话,它们将重新移至目前排在首位。

app光是云层的,但任务得到空洞的支撑。 我很容易通过更新其日期财产来转移任务,但我需要每项任务的命令财产,从零开始,将其提升到顶头。

我需要能够单独界定一个计数变量,并在每一份更新材料中增加。 我知道这部法律并不奏效,但它很容易解释需要做些什么:

count = 0

UPDATE `tasks` 
   SET `date` =  2010-01-04 , 
       `order` = `count`++ 
 WHERE `date` <  2010-01-04 

如果有可能,我不使用临时表格或使用QQLex外的柜台。

@OMG Ponies - 我开始认为,这只是不可能。

问题回答

我将作第二次发言。

UPDATE `tasks`
SET `date` =  2010-01-04 ,
count = ( SELECT COUNT(`task_id`) FROM `tasks` ) + 1
WHERE `date` <  2010-01-04 

不是经过测试,而是应该工作!

散射是一种巨大的工具,但如果能够利用JUSTQite,我会感到惊讶。 T-SQL的支持在这一点上是巨大的。

也许你可以更新记录中的现有价值;增加或背弃该记录,但这要求记录已经符合规定。

实际上,你可以在Sqlite使用添加物——检查。 http://www.sqlite.org/lang_expr.html;你只需要利用UPDATE的附加说明来加固反面和内质问,以便再次获得。 保证在交易中这样做,否则就会遇到一致的问题。

令我相信,你每行各列一栏。 如果是的话,我想你可以这样说:

UPDATE `tasks` 
SET 
`date` =  2010-01-04 , 
count = count + 1
WHERE `date` <  2010-01-04 

贵米知道这项工作如何......





相关问题
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: ...

热门标签