English 中文(简体)
如何获得一张薄片的ID数? [闭门]
原标题:How to get the row number of ID of a sql table? [closed]
  • 时间:2010-11-17 16:14:31
  •  标签:
  • php
  • sql
最佳回答

按职位划分,名册在数据库中没有任何实际意义(至少我可以想象)。 为什么你照顾到其实际的浏览地点?

你们知道第3次记录是你想要删除的记录吗? 配对一个识别码,在另一个领域使用一个短语,对独特地确定你希望查阅的记录有帮助。 浏览地点这样做不会对你造成影响。

如果你有5个记录,这些记录完全吻合,你只想删除其中1个记录,然后在你的DELETE发言结束前加上1个。 如果是确切的,那么就没有问题了。 第3、第5或第7条将问题搁置起来,因为它们与你的询问完全吻合。 因此,删除了你的配对问。

现在,正如你以某种顺序向用户提供数据表一样,这种数据可能或不会重复,并且允许用户选择删除一个字句。 你们正在占用实际的行刑地点,而不是把主要钥匙与每张显示的行刑分开。 然后,当用户选择删除时,你将只使用所附的主角,删除该行。

你说,“其他几个领域的主要关键是相同的” 这一点可能不错,因为你必须具备相同的主要钥匙。 我现在认为,你在数据库设计上有一些缺陷。 表格列出了你所从事工作的图象和样本。 如果你支持把 yourself带进设计的角子(如声音)的话,就毫无意义。

(我可以就其他员额发表评论,因此这一职位必须加以编辑。)

问题回答

你们也可以使用数量变量:

SELECT * FROM (
    SELECT t.*, 
        @rownum = @rownum + 1 AS rank
    FROM TABLE t, (SELECT @rownum := 0) r
    ORDER BY ID
    LIMIT 0, 34
) Q
WHERE rank in (3, 5, 9, 20, 34)

我尝试使用<条码>LIMIT,否则将每次扫描整个表格。


根据您对您情况的说明......

my scenario: I need to delete only a single row... there are several identical rows.. so using a delete with a where clause would delete all of them. Also, say there are 5 identical rows.. and i need to delete the third of those 5 rows...

确实,你需要小心,否则你就会删除错误的行文。 想用一个好的 cr来区分你希望从其他行文中删除的行文,也就是说,你想要删除最新的或除最新之外的一切。

你们可以使用“@湖”的延伸版,从每个群体中删除“Nth”,但在我开始之前,最好更多地了解你的具体问题。


Ah now here comes the monkey out of the sleeve:

假设有5个相同的增长。 用户在第3行中点击,要求删除......一个点火效率高的地方,因为它删除了与条款相匹配的第一行或与该条款相匹配的所有行。 这是否只是删除第三行,让所有其他人都无所作为?

就我所说的所有内容而言。 您在桌旁需要一个<代码>AUTO_INCREMENT领域,独特地确定您的记录。 然后,您可使用WHERE id = id。 感谢OMG Ponies治疗;

俄亥俄州自由党的部分条款与SélectT公司有关。

你们想要做什么?

表格中的排名并不具体。 你可以通过一个具体领域来命令他们,例如我假设的身份证是一种自动加固的价值。 如果你在通过国际发展法进行分类时想要第二行,你可以做这样的询问。

SELECT * FROM MyTable ORDER BY ID LIMIT 1,1

为了获得第19段,你将这样做。

SELECT * FROM MyTable ORDER BY ID LIMIT 18,1

使用限制说明重新编号。 如果你想要第10至19行,你可以使用。

SELECT * FROM MyTable ORDER BY ID LIMIT 9,10

在限额说明中,第1个数字是增长数(0个基数),第2个是汇回数。





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

热门标签