Mysql Error 1166
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Error Code 1166. Incorrect column name up vote 4 down vote favorite When I try to run a routine I get the following error: Error Code: 1166. Incorrect column name 'School.`School Name` = case when School.`Web School Name` is null then School.`School Name` els' I have double checked the column name and there is in fact a School.School Name. There are no leading or trailing spaces. Here is the beginning of the routine that the error is referring to: CREATE temporary TABLE tt_Step1 SELECT DISTINCT State.Code, State.Name, School.`School Name` = case when School.`Web School Name` is null then School.`School Name` else School.`Web School Name` end, School.`School ID` -- Into tt_Step1 FROM State LEFT JOIN School ON State.Code = School.State Where (School.`School ID` <> ... I recently converted this code from MSSQL to MySQL so there may be something I missed but I cannot find any errors. The original MSSQL query runs fine in SQL Server Management Studio but the converted version of it in MySQL does not. mysql sql share|improve this question edited Mar 28 '12 at 20:17 mellamokb 41.8k666105 asked Mar 28 '12 at 20:15 Travis P 75126 Column name with space can't happen in MySQL : dev.mysql.com/doc/refman/5.0/en/identifiers.html –David Bélanger Mar 28 '12 at 20:18 3 @DavidBélanger: That is absolutely not true. The only thing that linked doc says is cannot **end** with space characters. –mellamokb Mar 28 '12 at 20:19 1 Why down vote this? This is a perfectly fine SO question. –Joshua Enfield Mar 28 '12 at 21:14 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted Give this a shot: CREATE temporary TABLE tt_Step1 SELECT DISTINCT State.Code, State.Name, coalesce(School.`Web School Name`, School.`School Name`), School.`Schoo
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn http://stackoverflow.com/questions/9914995/mysql-error-code-1166-incorrect-column-name from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top ERROR 1166 (42000) at line 65203: Incorrect column name '' up vote 4 down vote favorite I have a big snapshot database size http://dba.stackexchange.com/questions/50450/error-1166-42000-at-line-65203-incorrect-column-name is about 44GB in mydata.sql. When I run it overnight, it show this error message: $ mysql -u root < mydata.sql ERROR 1166 (42000) at line 65203: Incorrect column name '' MySQL Version is 5.5.32-0ubuntu0.13.04.1 and this is a head from SQL file: $ head -n 10 mydata.sql -- MySQL dump 10.13 Distrib 5.5.22, for Linux (x86_64) -- -- Host: localhost Database: -- ------------------------------------------------------ -- Server version 5.5.22-55-log This is a snapshot of the line that making an issue: $ sed -n '65200,65203p' < mydata.sql /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ Line below 65203: /*!50013 DEFINER=`mysql`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `v_payments` AS select concat(`paypal_payments`.`id`,1) AS `id`, ***SNIP**** ,concat(`paypal_payments`.`payer_firstname`,' ',`paypal_payments`.`payer_lastname`,' ',`paypal_payments`.`payer_email`) AS `customer` ***SNIP*** from `paypal_payments` union select concat(`payment_data`.`id`,2) AS `CONCAT(id,2)`,`payment_data`.`id` AS `id`,`payment_data`.`txndate` AS `txndate`,`payment_data`.`valuedate` AS `valuedate`,concat('DBS - ',`payment_data`.`category`) AS `CONCAT('T - ',category)`,(`payment_data`.`credit` - `payment_data`.`debit`) AS `credit-debit` ***SNIP*** ,NULL AS `NULL`,NULL AS `NULL`,NULL AS `NULL`,`payment_data`.`note` AS `note`,`payment_data`.`remaining` AS `remaining` from `payment_data` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50
after the name causing trouble? 'company_type ' : the space https://khdocs.wordpress.com/2015/06/25/mysql-error-code-1166-incorrect-column-name/ after company_type column Never mind… it was the spaces after the column names!, only remove it , will work. to ‘company_type ‘ Share this:TwitterFacebookGoogleLike this:Like Loading... Related Post navigation Previous postERRORS in mysql displayed in language other than English. How to changeit?Next postError in import import net.proteanit.sql.DbUtils package innetbean Leave a mysql error Reply Cancel reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. (LogOut/Change) You are commenting using your Twitter account. (LogOut/Change) You are commenting using your Facebook mysql error 1166 account. (LogOut/Change) You are commenting using your Google+ account. (LogOut/Change) Cancel Connecting to %s Notify me of new comments via email. Search Search for: Recent Posts Only variable references should be returned byreference Introduction to PHP |Speak Khmer(Part-1) Cannot add genymotion toeclipse WAMP server Icon is red after we setup newwindow. How to get id from URL incodeigniter? adding a class to form_submit in PHPCodeigniter How to Disable Automatic Update Check of IDM (Internet DownloadManager) សំណួរត្រៀមរូបវិទ្យា សម្រាប់ប្រលងគ្រូអនុ ២០១៤ (ឯកទេស គណិត-រូប /រូប-គីមី) Codeigniter path functionsdefinitions PHP Framework forbeginners Search for: HTML CSS JAVASCRIPT JQUERY PHP Pages គោលបំនង របៀបទាញយកនិងតំឡើង JDK,JRE ,Netbean ឆ្នាំទី ៤ ឆ្នាំទី ១ ឆ្នាំទី ២ ឆ្នាំទី៣ ទំនាក់ទំនង ទំព៍រដើម អំពីខ្ញុំ Constructor in PHP Some PHP 5 ArrayFunctions CSS Tutorial CSS/CSS3 File Manipulation in Javaprogramming HTML HTML Tutorial Introduction of Basic JavaSyntax Introduction to JavaProgramming Introduction to PHP IT NORTON JAVA គោលបំនង របៀប ទាញយកនិងតំឡើង JDK,JRE ,Netbean Even Handling JAVASCRIPT JAVASCRIPT