Results 1 to 4 of 4

Thread: SQL syntax help

  1. #1
    gerald29 is offline Sugar Community Member
    Join Date
    Jan 2007
    Posts
    34

    Default SQL syntax help

    Hello, I am going blind looking at this sql statement. The following statement gets this error in Query Browser:

    Script line: 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''date_entered', 'date_modified', 'modified_user_id', 'created_by', 'deleted', 'a' at line 2

    insert into leads
    ('date_entered', 'date_modified', 'modified_user_id', 'created_by', 'deleted', 'assigned_user_id', 'team_id', 'do_not_call', 'converted', 'lead_source', 'status', 'salutation', 'first_name', 'last_name', 'title', 'phone_work', 'primary_address_street', 'primary_address_city', 'primary_address_state', 'primary_address_postalcode', 'account_name', 'ID')
    Values
    ("2008-04-06 01:01:01", "2008-04-06 01:01:01", "1", "1", 0, "1", "10fe74b0-e0d6-83fe-84c7-47c4ece91444", 0, 0, "InfoUSA", "New","Mr.", "David", "Abright", "President", "(469) 727-0450", "3200 W Pleasant Run Rd", "Lancaster", "TX", "75146", "Greet America", "InfoUSA-9999998-247343965");

    Can anyone see anything wrong with this statement?

    Thanks
    Gerald
    SugarCRM 5.1.0c
    Windows Server 2003 R2
    XAMPP Installation
    Apache / MySQL

  2. #2
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: SQL syntax help

    It's complaining right at the single quote and not showing the (, so it is very likely the problem is right there. I notice there is no space after leads or before ( on the next line. I don't know how MySQL handles line breaks, but I suspect it may be taking the ( as a function definition and therefore rejecting the tablename.

    Try an extra space there.

    The other thing I notice right away is that you're using single quotes instead of back ticks. Normally this will still work, but if you have a reserved word in there somewhere, a single quote won't escape it and you have to use a back tick. I don't see any reserved words near the error, so I don't expect it's this one, but something to remember.

    Phil

  3. #3
    atin is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    India
    Posts
    46

    Default Re: SQL syntax help

    Hiii
    gerald29,
    Try to write the code like in this way.Hope it will help you.

    insert into leads(date_entered,date_modified,modified_user_id, created_by,deleted, assigned_user_id,team_id,do_not_call,converted,lea d_source, status,salutation,first_name,last_name,title,phone _work, primary_address_street,primary_address_city, primary_address_state,primary_address_postalcode,a ccount_name,ID)
    Values("2008-04-06 01:01:01", "2008-04-06 01:01:01", "1", "1", 0, "1","10fe74b0-e0d6-83fe-84c7-47c4ece91444",0, 0, "InfoUSA", "New","Mr.", "David", "Abright", "President", "(469) 727-0450", "3200 W Pleasant Run Rd", "Lancaster", "TX", "75146", "Greet America", "InfoUSA-9999998-247343965");
    Thanks
    Atin

  4. #4
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: SQL syntax help

    Quote Originally Posted by atin
    insert into leads(date_entered,date_modified,modified_user_id, created_by,deleted, assigned_user_id,team_id,do_not_call,converted,lea d_source, status,salutation,first_name,last_name,title,phone _work, primary_address_street,primary_address_city, primary_address_state,primary_address_postalcode,a ccount_name,ID)
    Values("2008-04-06 01:01:01", "2008-04-06 01:01:01", "1", "1", 0, "1","10fe74b0-e0d6-83fe-84c7-47c4ece91444",0, 0, "InfoUSA", "New","Mr.", "David", "Abright", "President", "(469) 727-0450", "3200 W Pleasant Run Rd", "Lancaster", "TX", "75146", "Greet America", "InfoUSA-9999998-247343965");
    Atin is right.
    When listing field's name don't use any quotation mark; use them when you specify values (date, time, strings. Numeric values don't need quotes).
    What do you think the cookie monster eats ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 2010-03-16, 02:30 PM
  2. Replies: 1
    Last Post: 2008-02-22, 04:25 PM
  3. MS SQL Error
    By starace in forum General Discussion
    Replies: 7
    Last Post: 2007-06-27, 07:20 PM
  4. SQL syntax error on subpanel views
    By ian_h in forum Help
    Replies: 1
    Last Post: 2005-09-06, 06:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •