Solved

PHP/Mysql: Drop Column

Posted on 2007-11-30
2
839 Views
Last Modified: 2013-12-12
I am doing this:

mysql_query("ALTER TABLE model DROP COLUMN Column1");

but it says:

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 'column='Column1'' at line 1

But if i check the table, the column does get removed though...

0
Comment
Question by:jtcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
nplib earned 250 total points
ID: 20383001
You've got an error in another sql statement, probably one that runs after that column gets removed and tries to reference the removed column.
0
 
LVL 50

Assisted Solution

by:Steve Bink
Steve Bink earned 250 total points
ID: 20385671
I'm with nplib.  You'll have to narrow down when the error is coming back, and which query is causing it.  The manual has this to say about altering tables:

>>> In most cases, ALTER TABLE works by making a temporary copy of the original
>>> table. The alteration is performed on the copy, and then the original table is
>>> deleted and the new one is renamed. While ALTER TABLE  is executing, the
>>> original table is readable by other clients. Updates and writes to the table are
>>> stalled until the new table is ready, and then are automatically redirected to
>>> the new table without any failed updates.

If you have other updates or writes going on in the background (for example, on another httpd thread using the same database), those queries will be delayed until the ALTER TABLE is finished.  When they do run, they will on the new version of the table.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question