[ic] SQL INSERT

Scott Andreas interchange-users@interchange.redhat.com
Thu Feb 7 13:06:01 2002


Oops fix typos...the SQL portion is correct...but I still have the same
errors

hello list,

I'm still having trouble with an INSERT command based on a select

Is what I want is in my contacts table I'm selected certain criteria and
then inserting a note into my contactnotes table certain values

Here's what I have so far

contactnotes mysql table headers:
________________________________________
     |           |       |        |
code + contactno + notes + source + date
_____|___________|_______|________|______


[tmp dropdate][tag op=time]%Y%m%d[/tag][/tmp]
[tag flag write]contactnotes[/tag]
[query list=1
	st=db
	table=contactnotes
	sql="INSERT INTO contactnotes (contactno, notes, source, date) values
	(SELECT  catalogs.code, 'show catalog sent to user' , 'catalogs' ,
'[scratch dropdate]'
	FROM catalogs
	WHERE country = 'US' AND show_qty = '1' AND completed != '1')
"]
[/query]

The values that I want to insert into contactnotes are
code = AUTO_INCREMENT
contactno = catalogs.code    <--- code column from catalogs table
notes = Show catalog sent to user
source = catalogs
date = [scratch dropdate]

All based on the select statement

The error file shows...

/intranet/admin/insert_contactnotes.html Bad SQL statement: Parse error near
SELECT  catalogs.code, 'show catalog sent to user' , 'catalogs' , '20020207'
 	FROM catalogs
 	WHERE country = 'US' AND show_qty = '1' AND completed != '1')

 Query was: INSERT INTO contactnotes (contactno, notes, source, date) values
 	(SELECT  catalogs.code, 'show catalog sent to user' , 'catalogs' ,
'20020207'
	FROM catalogs
	WHERE country = 'US' AND show_qty = '1' AND completed != '1')



Any help would be appreciated


J. Scott Andreas :)
IS/Programmer/WebDevelopement
Learning Services, Inc.
e-mail: sandreas@learningservicesinc.com
phone: 1-800-877-9378 ext. 146
fax: (541) 744-2056


       ---    __o
     ---   _-\<,_
      --- (_)/ (_)


_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users

_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users