Question: Here I am using MySQL and I want my primary key to start with a letter, like D000. Then everytime I enter a new record the primary key auto increments like so:

D001
D002
D003.

How can I do this?

Answer: 
You can't `AUTO_INCREMENT` a column whose type is `VARCHAR`.

What you could do is make it `BIGINT` and `AUTO_INCREMENT`, and whenever you need it as `String`, you can prepend it with your letter `'D'` like:

```
Long dbKey = ...;
String key = "D" + dbKey;

```

You could create a stored procedure for this to set an "auto-incremented" string as the default value for this column, but it just doesn't worth the hassle. Plus working with numbers is always faster and more efficient than working with strings.
I'm not sure whether I get your question right, but shouldn't the following work?

```
CREATE TRIGGER myTrigger
  BEFORE INSERT
  ON myTable
  FOR EACH ROW
BEGIN
  SET NEW.myCustomId = COALESCE('D', RPAD('0',3,NEW.id)); 
END

```

for this case you NEED a "normal" primary key column..