On 17/05/2009 10:34 AM, velkropie wrote:
> 
> 
> John Machin wrote:
>> On 17/05/2009 1:35 AM, velkropie wrote:
>>> Hello,
>>>
>>> I'm trying to update two tables with one statement but, i'm not getting
>>> something right. can someone here help me , or guide me to the right
>>> place
>>> to get help?
>>>
>>> Thanks
>>>
>>> "UPDATE funrecipes, ingredients SET funrecipes.recipetitle,
>>> funrecipes.copyright, funrecipes.directions, ingredients.ingredient_name 
>>> WHERE ingredients.pk = funrecipes.pk"
>>>
>>> this is returning a database error, any ideas?
>> A "database error"? Nothing to do with a database, it's just not valid 
>> SQL. Read this: http://www.sqlite.org/lang_update.html
>>
>> There are _*TWO*_ syntax problems with your UPDATE statement:
>> (1) it is not possible to update more than one table in the same UPDATE 
>> statement
>> (2) you don't say *what* each column must be set to ... the syntax is
>>      SET column_name1 = expression1, column_name2 = expression2, ...
>>
>> And possibly one logic problem ... your WHERE clause would look a bit 
>> suss even in a SELECT statement, especially if "pk" means "primary key".
>>
>> HTH,
>> John
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
> 
> i'm sorry for not placing more information, and thanks for your help.
> the application has two tables.
> recipes tables has the following fields:
> pk which is the primary field and autoincrements
> directions
> copyright
> another table call ingredients
> ingredient_name
> ingredient_id(pk)
> pk (which i was hoping to tie to recipes, since pk is the (pk) for recipes)

Hope has little place in database design.

> since i plan to have many ingredients display at once i decided to set it in
> another table.

The relationship between ingredients and recipes is many-to-many; 
consider having a THIRD table which tells what quantity of ingredient I 
(if any) is used in recipe R.
Consider reading up on database design.
Consider "borrowing" a schema from one of the zillion ** 2 recipe 
packages out there.

> the fields will be updated by user imput

Consider validating the "imput" :-)

HTH,
John
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to