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
  • 704,970
  • 168
  • 1,303
  • 1,425
Saurabh Saxena
  • 2,743
  • 9
  • 29
  • 44

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
  • 88,818
  • 14
  • 143
  • 153
  • 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