How to get ID column data back to Livecode
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to get ID column data back to Livecode
Hi, all!
When using "SELECT * FROM tTableName"
all data from that table are being retrieved.
My concern is How to get the ID column back from the database.
The ID column is just the most left column in the DB, recording 1,2,3,4,5...
Is there a sentence to retrieve that information?
Thanks a lot,
Michael
When using "SELECT * FROM tTableName"
all data from that table are being retrieved.
My concern is How to get the ID column back from the database.
The ID column is just the most left column in the DB, recording 1,2,3,4,5...
Is there a sentence to retrieve that information?
Thanks a lot,
Michael
Re: How to get ID column data back to Livecode
http://forums.runrev.com/phpBB2/viewtop ... 437#p84437
Replace "Password" with "ID" (No quotes!) and leave out the "WHERE" stuff!

Replace "Password" with "ID" (No quotes!) and leave out the "WHERE" stuff!

Re: How to get ID column data back to Livecode
I'm not really sure to understand your question...ECNU4271 wrote: My concern is How to get the ID column back from the database.
The ID column is just the most left column in the DB, recording 1,2,3,4,5...
Are you talking about the name of the column that contains those ID ?
If it's for instance "theid" then you can use a SQL query such as :
Code: Select all
SELECT theid FROM tTableName
Re: How to get ID column data back to Livecode
NONO, ID is not a column that I name it "ID" .Klaus wrote:http://forums.runrev.com/phpBB2/viewtop ... 437#p84437
Replace "Password" with "ID" (No quotes!) and leave out the "WHERE" stuff!
As I said, in the database, the most left column is the ID column
Re: How to get ID column data back to Livecode
You mean the "Primary Key" http://www.w3schools.com/sql/sql_primarykey.asp?
Sorry, no idea how to retrieve this if you did not define a "primary key" database field.
Sorry, no idea how to retrieve this if you did not define a "primary key" database field.
Re: How to get ID column data back to Livecode
When checking data of the table in MySQL
Table: (I only create Name, Password, Gender, Age)
ID Name Password Gender Age
1 Jack 123456 Male 19
2 Mary 123455 Female 18
3 Michael 123454 Male 20
4 ..
5 ..
6 ..
In this case, if I use "SELECT * FROM tTableName"
I'll get :
Name Password Gender Age
Jack 123456 Male 19
Mary 123455 Female 18
Michael 123454 Male 20
..
..
What I want is to get exactly what I can see from the database (includes ID column which is created by MySQL ifself)
ID Name Password Gender Age
1 Jack 123456 Male 19
2 Mary 123455 Female 18
3 Michael 123454 Male 20
4 ..
5 ..
6 ..
So in this case, is ID the primary key?
and how can I achieve that?
Table: (I only create Name, Password, Gender, Age)
ID Name Password Gender Age
1 Jack 123456 Male 19
2 Mary 123455 Female 18
3 Michael 123454 Male 20
4 ..
5 ..
6 ..
In this case, if I use "SELECT * FROM tTableName"
I'll get :
Name Password Gender Age
Jack 123456 Male 19
Mary 123455 Female 18
Michael 123454 Male 20
..
..
What I want is to get exactly what I can see from the database (includes ID column which is created by MySQL ifself)
ID Name Password Gender Age
1 Jack 123456 Male 19
2 Mary 123455 Female 18
3 Michael 123454 Male 20
4 ..
5 ..
6 ..
So in this case, is ID the primary key?
and how can I achieve that?
Re: How to get ID column data back to Livecode
Ah ah ah I got it now.
The number you are talking about... are just displayed by your MySQL client software (like Excel), line per line.
Right ?
So to do what you want (to see a unique number for each record) you need to add a column to your database.
Currently you have :
Name, Password, Gender, Age
Add one column : myid (see screenshot)
-give it the type like INT
-give it the "AUTO INCREMENT" default
-make it the primary key (check if primary key is not already set on the column "name" for instance)
The number you are talking about... are just displayed by your MySQL client software (like Excel), line per line.

Right ?
So to do what you want (to see a unique number for each record) you need to add a column to your database.
Currently you have :
Name, Password, Gender, Age
Add one column : myid (see screenshot)
-give it the type like INT
-give it the "AUTO INCREMENT" default
-make it the primary key (check if primary key is not already set on the column "name" for instance)
Re: How to get ID column data back to Livecode
aha
great, thanks Bangkok!
great, thanks Bangkok!