-4

I have my database with table test. It has a primary id "Id" which is auto-increment. Now the id is in the format 1,2,3.. . .Is it possible to store the primary Id as A1,A2,A3 .. . . and so on(with auto-increment).

William
  • 942
  • 2
  • 12
  • 25
Anusha
  • 1
  • 5
  • php is not a database. Do you use mysql as your database? – Linkan Mar 01 '17 at 11:47
  • 3
    Possible duplicate of [Automatically add letters in front of an auto-increment fieild](http://stackoverflow.com/questions/9648253/automatically-add-letters-in-front-of-an-auto-increment-fieild) – Linkan Mar 01 '17 at 11:49
  • Possible duplicate of [MySQL auto increment plus alphanumerics in one column](http://stackoverflow.com/questions/2380923/mysql-auto-increment-plus-alphanumerics-in-one-column) – Manuel Spigolon Mar 01 '17 at 12:10
  • Depends entirely on what you're expecting `A1`, `A2`, `A3` and so on to be? For all we know that might just be 161, 162 and 163 in hexadecimal... (probably isn't but *could* be) – CD001 Mar 01 '17 at 15:53

1 Answers1

2

You can fetch that id in A1,A2,A3

 SELECT concat('A',id) FROM table_name;

You cant create that of primary key format in mysql

denny
  • 2,084
  • 2
  • 15
  • 19