0

In Oracle, the below statement works perfectly:

INSERT INTO fake_table (names, gender)
     VALUES ( (SELECT distinct(name)
                 FROM target_table),
             'F');

I don't want to touch the SELECT statement - SELECT distinct(name) FROM target_table

Being said that, I want same fucntionality in MySQL. I got many codes with Static values within Select statement, but I am not looking for that. Simply put; I am looking to initialize 'F' separatly.

Thank you for your help in advance. :)

user3360094
  • 57
  • 10
  • tl;dr `rownum` is Oracle specific functionality. You're going to have to change it... sorry. – Ben Sep 10 '14 at 11:50
  • possible duplicate of http://stackoverflow.com/questions/9008539/limit-results-in-mysql (for example) – Ben Sep 10 '14 at 11:52
  • Thx for the quick reply @Ben... however I am not interested in rownum alternative. I am looking to initialize 'F' apart from Select statement. Pardon me if my question was not straight. – user3360094 Sep 10 '14 at 12:00

1 Answers1

2
INSERT INTO fake_table (names, gender)
  SELECT s.*, 'F'
    FROM (
      -- your query
      SELECT distinct(name) FROM target_table
    ) s
Rimas
  • 5,904
  • 2
  • 26
  • 38