This may help you:
mysql> create table locais(
-> id int,
-> type varchar(2),
-> `desc` varchar(10));
Query OK, 0 rows affected (0.12 sec)
mysql> select * from locais;
+------+------+-------+
| id | type | desc |
+------+------+-------+
| 1 | t1 | sk |
| 2 | t2 | dsk |
| 3 | t1 | ddfsk |
+------+------+-------+
3 rows in set (0.00 sec)
mysql> select distinct type from locais;
+------+
| type |
+------+
| t1 |
| t2 |
+------+
2 rows in set (0.00 sec)
mysql> create table ztipos(id int auto_increment primary key, type
varchar(2));
Query OK, 0 rows affected (0.14 sec)
mysql> insert into ztipos(type) select distinct type from locais;
Query OK, 2 rows affected (0.18 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from ztipos;
+----+------+
| id | type |
+----+------+
| 1 | t1 |
| 2 | t2 |
+----+------+
2 rows in set (0.00 sec)
mysql>
I think the ztipos table definition has a problem. If you post that we may
be able to help better....
Anoop
(anokun7)
On 2/18/07, Miguel Vaz <dante@stripped> wrote:
>
>
> Hi,
>
> I have a table LOCAIS with:
>
> id type desc
> 1 t1 blah blah
> 2 t1 uihuih
> 3 t2 pokpokp
>
>
> I want to list only the distinct types and create a table with
> those results.
> I know how to list the distinct and i thought i got the insert
> right, but it doesnt work:
>
> INSERT INTO ztipos('type') SELECT DISTINCT type FROM locais
>
> Whats wrong with that command?
> I want the result to be:
> results table ZTIPOS:
>
> id type
> 1 t1
> 2 t2
>
>
> Thanks
>
> Miguel
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1
>
>
--
Thanks and best regards,
Anoop