Unix Technical Forum

Help with delete query please

This is a discussion on Help with delete query please within the MySQL forums, part of the Database Server Software category; --> Hi Having problem with delete query. Below is query: $unconfirmedstatus = 'Unconfirmed'; $firstquery = "DELETE FROM Pendingsales WHERE time ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:47 AM
Donna Elles
 
Posts: n/a
Default Help with delete query please

Hi
Having problem with delete query. Below is query:

$unconfirmedstatus = 'Unconfirmed';
$firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60 MINUTE
AND status = $unconfirmedstatus";
$result = mysql_query($firstquery) or die ("Failed query of" . $firstquery .
mysql_error());

Error message is as follows:

Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'

Cant see where I'm going wrong. Unconfirmed is not the column - status is the
column.

Any help greatly appreciated.
Donna

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:47 AM
Paul Lautman
 
Posts: n/a
Default Re: Help with delete query please

Donna Elles wrote:
> Hi
> Having problem with delete query. Below is query:
>
> $unconfirmedstatus = 'Unconfirmed';
> $firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL
> 60 MINUTE AND status = $unconfirmedstatus";
> $result = mysql_query($firstquery) or die ("Failed query of" .
> $firstquery . mysql_error());
>
> Error message is as follows:
>
> Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() -
> INTERVAL 2 MINUTE AND status = Unconfirmed Unknown column
> 'Unconfirmed' in 'where clause'
>
> Cant see where I'm going wrong. Unconfirmed is not the column -
> status is the column.
>
> Any help greatly appreciated.
> Donna


You missed the quotes to change Unconfirmed into a constant. Try:
$firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60
MINUTE
AND status = '$unconfirmedstatus'";


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:47 AM
Gordon Burditt
 
Posts: n/a
Default Re: Help with delete query please

>$unconfirmedstatus = 'Unconfirmed';
>$firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60 MINUTE
>AND status = $unconfirmedstatus";
>$result = mysql_query($firstquery) or die ("Failed query of" . $firstquery .
>mysql_error());
>
>Error message is as follows:
>
>Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
>MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'
>
>Cant see where I'm going wrong. Unconfirmed is not the column - status is the
>column.


No, as written, Unconfirmed is a (nonexistent) column. Perhaps you meant:
where status = 'Unconfirmed'

Gordon L. Burditt
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 08:47 AM
Bill Karwin
 
Posts: n/a
Default Re: Help with delete query please

Donna Elles wrote:
> Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
> MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'


Unconfirmed with no quotes around it is interpreted as a column name.
'Unconfirmed' with quotes around it is interpreted as a string literal.

Regards,
Bill K.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com