Jump to content

SELECT DISTINCT?


B0b

Recommended Posts

Hi everyone,

 

I'm trying to copy a column from a table to another while removing duplicate entries then add 3 other columns and fill one of them with numbers from 1 to X -> that's what I'm unable to do.

 

Here's my goal:

 

Table 1:

 

1  bob1

2  bob2

3  bob2

4  bob3

5  bob4

 

Table 2:

 

1 bob1 jack marc

2 bob2 frank stu

3 bob3 some dude

4 bob4 foo bar

 

Here's what I got:

 

<?php
$new = 'tmp_' . $original;

mysql_query(
	"CREATE TABLE $new AS
	SELECT DISTINCT email
	FROM $original" );

 

I'm confused as to how to add the first column.

 

Thanks!  :)

Link to comment
Share on other sites

Let's be more specific: I know the column may be added using:

 

<?php
mysql_query(
"ALTER TABLE $tmpName
ADD column type" );

 

But I don't know how I may fill it since I may not refer to anything using WHERE.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.