Page 1 of 1
How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 4:18 pm
by ECNU4271
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
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 4:30 pm
by Klaus
http://forums.runrev.com/phpBB2/viewtop ... 437#p84437
Replace "Password" with "ID" (No quotes!) and leave out the "WHERE" stuff!

Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 6:33 pm
by bangkok
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...
I'm not really sure to understand your question...
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 :
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 8:26 pm
by ECNU4271
NONO, ID is not a column that I name it "ID" .
As I said, in the database, the most left column is the ID column
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 8:34 pm
by Klaus
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.
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 8:51 pm
by ECNU4271
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?
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 9:47 pm
by bangkok
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)
Re: How to get ID column data back to Livecode
Posted: Fri Aug 30, 2013 10:44 pm
by ECNU4271
aha
great, thanks Bangkok!