View Single Post
  #2  
Old 03-28-2014, 06:21 AM
moofta
Sarnak
 
Join Date: Jan 2014
Location: United Kingdom
Posts: 53
Default

with what did you create the new table- by hand or using Navicat/HeidiSQL? (I would suggest doing so if you're not very familiar with SQL in general)

I use HeidiSQL and it's pretty simple to use, surprisingly fast,.. and free!
  1. When you create your table, create the first column in the "Basic" tab and call it "id".
  2. Give it a data type of "INT".
  3. Under the "Default" column, select "AUTO_INCREMENT".
  4. Then click on the "Indexes" tab, click on your id field, then click on "Add". An index called "Index1" will appear.
  5. Click on the "type/length" entry for Index1 (which probably says "PRIMARY"), select "PRIMARY".
  6. Then click "save" at the bottom

Manually you can do this when creating (just copy/pasting a table I created):-

Code:
CREATE TABLE IF NOT EXISTS `zone_drops` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `zone_id` int(11) NOT NULL,
  `zone_name` varchar(50) NOT NULL,
  `item_id` int(11) NOT NULL,
  `item_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
If you use Navicat or other, there will be a way to set the default value to AUTO_INCREMENT, and also to make it the primary key. That way your ID will always be unique and auto-generated.
Reply With Quote