how to create table with ID number compose of letter and number. example "AS-0001" so that everytime i will search a record i will only use the ID number.
Asked
Active
Viewed 498 times
-1
-
What you have tried and what output you have got? – Balaji Kandasamy Feb 04 '13 at 12:33
-
2Just do it? You'd have to store the value in a `varchar` field... – Pekka Feb 04 '13 at 12:33
-
With slight modification all are on same notes - http://stackoverflow.com/questions/14678538/what-type-to-use-for-an-id-number-composed-of-letters-and-numbers-which-will-inc http://stackoverflow.com/questions/14680122/how-to-auto-increment-id-numbers-with-letters-and-numbers http://stackoverflow.com/questions/14686875/how-to-create-table-with-id-number-compose-of-letter-and-number http://stackoverflow.com/questions/14686346/how-to-create-auto-increment-id-number – swapnesh Feb 04 '13 at 12:35
2 Answers
0
Simple:
$sql = "CREATE TABLE `table_name` (
id VARCHAR(7),
randomDataField VARCHAR(255),
PRIMARY KEY (id)
)";
Then id will be a var char, so you can store both numbers and letters.
Although, this ID would not auto increment and you'd need to manually assign the ids.

EM-Creations
- 4,195
- 4
- 40
- 56
0
CREATE TABLE `AS-0001` (
id VARCHAR(7),
randomDataField VARCHAR(255),
PRIMARY KEY (id)
)

Malaiyandi Murugan
- 393
- 3
- 15