List:General Discussion« Previous MessageNext Message »
From:Daniel Rossi Date:September 11 2003 4:12am
Subject:Re: Getting the primary key in an update query
View as plain text  
that works cheers

>>> "Roger Baklund" <roger@stripped> 09/11/03 10:48am >>>
* Daniel Rossi
> Hi there i was wondering if there was anyway to determine the
> primary key field instead of explicitly setting it in an update
> sql query ?
>
> for instance i'd like to go update table *** where primarykey=1
> instead of where id=1 as the primary key is named differentrly
> for each table and i'm trying to create a global data manager,
> let me know thanks.

Since 3.23.11 you can use _rowid as an alias for an integer type unique
indexed column:

<URL: http://www.mysql.com/doc/en/News-3.23.11.html >

mysql> use test
Database changed
mysql> create table testrowid (x int not null primary key);
Query OK, 0 rows affected (0.38 sec)

mysql> insert into testrowid values (1),(2),(3);
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from testrowid where _rowid=2;
+---+
| x |
+---+
| 2 |
+---+
1 row in set (0.00 sec)

--
Roger


Thread
Getting the primary key in an update query(Daniel Rossi)11 Sep
  • Re: Getting the primary key in an update queryRoger Baklund11 Sep
Re: Getting the primary key in an update query(Daniel Rossi)11 Sep