0

I have a table with following schema

Sample table

email        |  name  |  address 
1@gmail.com  |  A     |  CA

I want the same set of record with five different static email addresses

Expected output

email              |   name   |   address
static1@gmail.com  |   A      |   CA
static2@gmail.com  |   A      |   CA
static3@gmail.com  |   A      |   CA
static4@gmail.com  |   A      |   CA
static5@gmail.com  |   A      |   CA

Is this possible?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Saurabh Saxena
  • 3,005
  • 10
  • 31
  • 46

1 Answers1

1

Try

SELECT CONCAT('static', @n := @n + 1, '@', SUBSTRING_INDEX(email, '@', -1)) email,
       `name`,
       address
  FROM table1 CROSS JOIN  
       INFORMATION_SCHEMA.COLUMNS JOIN
       (SELECT @n := 0) n
 LIMIT 5

Output:

|             EMAIL | NAME | ADDRESS |
--------------------------------------
| static1@gmail.com |    A |      CA |
| static2@gmail.com |    A |      CA |
| static3@gmail.com |    A |      CA |
| static4@gmail.com |    A |      CA |
| static5@gmail.com |    A |      CA |

SQLFiddle

peterm
  • 91,357
  • 15
  • 148
  • 157
  • yeah this does it, but it sounds like you just gave a spammer a solution to generate a bunch of emails. – DRapp Apr 07 '13 at 12:00