Web Hosting Talk







View Full Version : SQL query question


Santana
11-20-2000, 01:38 AM
Hello all, I am new to mySQL and currently having some difficulties on changing fields data.

I am importing data from flat text database and the ID number field has some duplicates which will screw my data up.
Is there any query to be run to change or make a new ID numbers for my table?

Thank you for any help.

rgds

HX
11-20-2000, 10:13 AM
Use auto_increment

If you have your own ID field, delete it
and use the auto_increment-based ID field

CREATE TABLE mytable (
my_id int(11) DEFAULT '0' NOT NULL auto_increment,
name varchar(60) DEFAULT '' NOT NULL,
contact varchar(60) DEFAULT '' NOT NULL,
email varchar(60) DEFAULT '' NOT NULL,
login varchar(10) DEFAULT '' NOT NULL,
passwd varchar(10) DEFAULT '' NOT NULL,
extrainfo text NOT NULL,
PRIMARY KEY (my_id)
);

Santana
11-20-2000, 11:40 AM
Thanks HX. It works!

but how can we start from 1000 instead of 1. is it possible?

thanks

kunal
11-20-2000, 01:19 PM
Like this
my_id int(11) DEFAULT '1000' NOT NULL auto_increment,

riffola
11-22-2000, 12:43 AM
Hi,

I run a music site, and I wanted to make my lyrics section work via a database, but when I tried making a table for it, I found out that the max characters is 255.

Any idea as to what I should do?

kunal
11-22-2000, 01:06 AM
name the filed as text and not varchar :)

riffola
11-22-2000, 01:14 AM
Great thanks for the tip! I'll try first thing tomorrow morning.

riffola
11-22-2000, 11:42 AM
Thanks Kunal it worked!

kunal
11-22-2000, 11:54 AM
Cool... glad I could help :)

mkaufman
11-22-2000, 01:25 PM
If you'd like more information on MySQL, check out http://www.mysql.com