0

my attempt:

SELECT * into table_joe FROM table_names WHERE username LIKE '%Joe%'

But this fails saying the new table (table_joe) is an undeclared variable.

Thank you!

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Rainstick
  • 3
  • 1

1 Answers1

0

You need to use INSERT here, not SELECT:

INSERT INTO table_joe
SELECT *
FROM table_names
WHERE username LIKE '%Joe%';

But note that in general it very advisable to always explicitly list out which columns are the target/source in an insert. So, something like the following is better practice:

INSERT INTO table_joe (col1, col2, col3)
SELECT col1, col2, col3
FROM table_names
WHERE username LIKE '%Joe%';
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360