Page 1 of 1

adding and deleting from a data base

Posted: Mon Nov 20, 2006 4:37 pm
by aussie_clint
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


i have worked out how to display results by comparing table, can some one tell me how to add and delet using this qury

in this one i want to delet the products that arnt in the `newprice list` table
[syntax="sql"]SELECT `price list`.PartNumber, `price list`.Description
FROM `price list`
LEFT JOIN `newprice list` ON `price list`.PartNumber = `newprice list`.PartNumber
WHERE `newprice list`.PartNumber IS NULL;
and in this one i want to add the new products into the `price list' table

Code: Select all

SELECT `newprice list`.PartNumber, `newprice list`.Description
FROM `newprice list`
LEFT JOIN `price list` ON `newprice list`.PartNumber = `price list`.PartNumber
WHERE `price list`.PartNumber IS NULL;

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Nov 21, 2006 10:23 am
by GeertDD
When wanting to delete or insert records from a database you won't come far using SELECT only.

The very basic syntax for deleting rows is:

Code: Select all

DELETE row FROM table [WHERE condition]
And for insertion:

Code: Select all

INSERT INTO table (column1[, column2]) VALUES (value1[, value2])
Have a look at sqlcourse.com for example.