adding and deleting from a data base

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

adding and deleting from a data base

Post 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]
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post 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.
Post Reply