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!
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!
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%';