Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2006, 04:53 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default add column if not exist

Hi,

I would like to add a column to a table.
Code:
ALTER TABLE tb_form
ADD Form_subject char(50)
How ever I want this query to be done if the column doesn't allready exists in the table.

how can this be done

thnx

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old February 16th, 2006, 01:57 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't think you can do this directly using sql.

You could run a "DESCRIBE yourTableName;" query, then check the value of the "Field" column for each record to find out whether it matches the field name you want.

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a new column into gridview? Bryan Stanley ASP.NET 2.0 Basics 0 September 12th, 2007 10:49 PM
Add 1 to next column deontae45 SQL Language 2 December 18th, 2006 01:42 PM
Add a Column to a DataGrid infernokodiak C# 7 January 18th, 2006 04:06 PM
Add Column in a View rekha_jsr Oracle 1 December 5th, 2004 04:58 AM
add column (C#) kobystud C# 1 July 21st, 2004 10:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.