DELETE * FROM

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
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

DELETE * FROM

Post by SidewinderX »

whats wrong with this?

Code: Select all

function DesignersDelete($designer, $site) {
    global $prefix, $db;
	$sql = mysql_query("DELETE * FROM ".$prefix."_theme_authors WHERE author='$designer'") or die("Error: ".mysql_error()); 
	Header("Location: admin.php?op=ThemeSystem");
}
It dosnt delete the row, any ideas what is wrong with this?
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

You cannot specify a column, it's simply

Code: Select all

DELETE FROM sometable WHERE somecolumn= 1;
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post by SidewinderX »

hm...im a little confused now

say i have the table named information, and the table is setup as follows
name address
John 350 PHP Lane
Bob 665 HTML Road
Jim 001 CSS Avenue
how would i design the query so it deletes
Bob 665 HTML Road
from the table?

it would be

Code: Select all

$sql = mysql_query("DELETE * FROM information WHERE name='Bob'") or die("Error: ".mysql_error());
wouldnt it?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

Code: Select all

"DELETE * FROM information WHERE name='Bob'"
and maybe try this

Code: Select all

function DesignersDelete($designer, $site) {
    global $prefix, $db;
        $sql = "DELETE * FROM ". $prefix ."_theme_authors WHERE author='$designer'";
        $query = mysql_query($sql) or Die("Error: " . mysql_error());
        Header("Location: admin.php?op=ThemeSystem");
}
a query is nothing more then a string. what you had originally should have worked, but the code above should work... unless your colum names are different or something.
Last edited by dull1554 on Tue Jul 11, 2006 2:47 pm, edited 1 time in total.
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

No, '*' is a column specifier.

Code: Select all

DELETE FROM information WHERE name='Bob';
MySQL Manual: SQL syntax
MySQL Manual: DELETE syntax
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

/////edit...im dumb
Last edited by dull1554 on Tue Jul 11, 2006 2:50 pm, edited 1 time in total.
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post by SidewinderX »

bdlang wrote:No, '*' is a column specifier.

Code: Select all

DELETE FROM information WHERE name='Bob';
MySQL Manual: SQL syntax
MySQL Manual: DELETE syntax
ohhhh that works like a charm :lol:

ty
Post Reply