Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CREATE TABLE ... LIKE not working

Need help trying to create a table using CREATE TABLE ... LIKE, code is below, error given is

Incorrect syntax near the keyword 'LIKE'

CREATE TABLE jobserve_reports LIKE Jobserve

I've tried putting the LIKE in quotations with no luck, tried making it a temporary table, using curly braces and nothing has worked. Am at my wits end.

like image 277
Matt Warner Avatar asked Nov 25 '25 10:11

Matt Warner


2 Answers

In SQL Server, we can create using:

SELECT * 
INTO newtable 
FROM oldtable 
WHERE 1 = 0;
like image 149
Be1ng_Kr1Sh Avatar answered Nov 27 '25 00:11

Be1ng_Kr1Sh


If LIKE is not available in your db you could use create select

CREATE TABLE jobserve_reports AS 
select * from  Jobserve

or equivalent

eventuallly using

CREATE TABLE jobserve_reports AS 
select * from  Jobserve
where 1 = 2 

for get no result

like image 20
ScaisEdge Avatar answered Nov 27 '25 00:11

ScaisEdge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!