[prog] mysql

Michelle Murrain tech at murrain.net
Wed Nov 5 20:27:13 EST 2003


On Wed, 2003-11-05 at 18:55, Saint-Wolfe wrote:
> Hi,
> 
> I'm trying to add some information to a table that already exists in a 
> database, the table I wish to add
> the info to is called address
> 
> I have a file called info.sql which contains the following:
> 
> select "INSERT INTO address (p_code, addr_type, city, state) VALUES (", 
> f_code, ",'", 'Current', "','", 'Albany', "','", 'NY', "');" from 
> faculty

The SQL syntax is incorrect. First off, is the table that already exists
the faculty table?

The syntax for inserting data from an existing table is like:

INSERT into address (p_code,city,state) SELECT p_code,city,state from
faculty WHERE .....

> 
> I have a second file called info2.sql which contains:
> 
> select "UPDATE address SET email = '", 
> lower(concat(left(f_name,1),concat(l_name,"@nyu.edu'"))) AS "2", "where 
> email = '' and p_code = ", f_code from faculty

Again, the SQL syntax is wrong.

Basic update SQL looks like" UPDATE address SET email = ... WHERE ...

There is a basic SQL reference on the mysql site: 
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Reference
-- 
.Michelle
---------------------------
Michelle Murrain
mmurrain at dbdes.com
Database Designs Associates, Inc.
Boston   617.889.0929
Amherst  413.253.2874
Cell 	 413.222.6350
www.dbdes.com

AIM:pearlbear0 ICQ:129250575

"Our capacity to make peace with another person and with the world
depends very much on our capacity to make peace with ourselves." -- Thich Nhat Hanh



More information about the Programming mailing list