-3
/*Create the Registered guest table*/
create table Registered guest 
(
    Guest_ID integer not null,
    F_Name varchar (50) not null,
    L_Name varchar (50) not null,
    Start_date date not null CHECK (Start_date <=End_date),
    End_date date not null, 
    Dietary_needs varchar(20),
    Acco_needs varchar (50),
    Number_ of_ accompanying guests integer(5),

    Primary key (Guest_ID)
); 

I am getting the following error

near "guest": syntax error: create table Registered guest

I can't find the syntax error !

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    Can you pick one SQL flavour, not 3? – Alex Hall May 07 '18 at 23:48
  • 1
    Please don't tag spam. SQL Server is not MySQL is not SQLite. The first thing you need to do is figure out which DBMS you're actually using. The next is to stop using tags that are not related to that DBMS. You wouldn't get help calling your auto repair shop and asking *I have a problem with my car. It's a Ford, Chevy, Dodge, or Porsche. How much to replace the starter?* – Ken White May 07 '18 at 23:54
  • 2
    Removed all conflicting / irrelevant tags and added the generic sql one. Pls add the one product tag back that you use. – Shadow May 07 '18 at 23:56
  • 3
    What's the database? – The Impaler May 07 '18 at 23:59
  • An identifier containing "odd" characters like space and others needs to be delimited, e.g. `"Number_ of_ accompanying guests"`. – jarlh May 08 '18 at 06:54

3 Answers3

6

The space in the table name is a problem. Best avoid spaces and just call the table Registered_guest.

If you really want spaces in a name, use double quotes, as in

 create table "Registered guest" (
Alex Hall
  • 34,833
  • 5
  • 57
  • 89
  • According to https://stackoverflow.com/questions/25141090/sqlite-use-backticks-or-double-quotes-with-python?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa SQLite accepts backticks and square brackets, for compatibility with both MySQL and SQL-Server. And you can also use double quotes, which are the SQL standard. – Barmar May 07 '18 at 23:53
  • @Barmar thanks, I didn't know about the double quotes. – Alex Hall May 07 '18 at 23:55
2
...
Number_ of_ accompanying guests integer(5),
...

You are missing an underscore between 'accompanying' and 'guests'

Ryne Heron
  • 46
  • 4
1

Other than the issue with the spaces in table and column names, the CHECK constraint is missing a comma before it. The correct query would then be:-

create table Registered_guest (
    Guest_ID integer not null,
    F_Name varchar (50) not null,
    L_Name varchar (50) not null,
    Start_date date not null,
    End_date date not null, 
    Dietary_needs varchar(20),
    Acco_needs varchar (50),
    Number_of_accompanying_guests integer,
    Primary key (Guest_ID),
    CHECK (Start_date <=End_date)
);