UPDATE syntax

UPDATE syntax

am 14.12.2007 01:20:15 von Ron Piggott

Can anyone see something wrong with this syntax?

UPDATE `advertisements` INNER JOIN `advertisements_rate_plans` ON
`advertisements.rate_plan` = `advertisements_rate_plans.reference` SET
`advertisements.displayed` = 0 WHERE `advertisements.start_date` <=
'2007-12-13' AND `advertisements.end_date` >= '2007-12-13' AND
`advertisements.approved` =1 AND `advertisements.paid` =1 AND
`advertisements.displayed` =1 AND `advertisements_rate_plans.type` =2

I am getting this error message:

#1054 - Unknown column 'advertisements.displayed' in 'field list'

There is a column called "displayed" in table "advertisements".

I am on the http://dev.mysql.com/doc/refman/5.0/en/update.html page and
I am missing something.

Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: UPDATE syntax

am 14.12.2007 01:33:57 von Gary Wardell

Hi,

I'm a beginner at PHP and MySql but a long time MS SQL server user.

Maybe it should be `advertisements`.`displayed` instead?

I just did a test and my Query browser doesn't like `interestcodes.id` but likes `interestcodes`.`id`. Notice the quotes
(accents) on each side to the period.

Gary

> -----Original Message-----
> From: Ron Piggott [mailto:ron.php@actsministries.org]
> Sent: Thu, December 13, 2007 7:20 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] UPDATE syntax
>
>
> Can anyone see something wrong with this syntax?
>
> UPDATE `advertisements` INNER JOIN `advertisements_rate_plans` ON
> `advertisements.rate_plan` = `advertisements_rate_plans.reference` SET
> `advertisements.displayed` = 0 WHERE `advertisements.start_date` <=
> '2007-12-13' AND `advertisements.end_date` >= '2007-12-13' AND
> `advertisements.approved` =1 AND `advertisements.paid` =1 AND
> `advertisements.displayed` =1 AND `advertisements_rate_plans.type` =2
>
> I am getting this error message:
>
> #1054 - Unknown column 'advertisements.displayed' in 'field list'
>
> There is a column called "displayed" in table "advertisements".
>
> I am on the
> http://dev.mysql.com/doc/refman/5.0/en/update.html page and
> I am missing something.
>
> Ron
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: UPDATE syntax

am 14.12.2007 02:08:57 von Trevor Gryffyn

Sorry, I didn't read the whole post, but wanted to point something out:
`interestcodes`.`id` is valid
interestcodes.id is valid
`interestcodes.id` is going to try to find a column named "itnerestcodes.id"
somewhere with no table association.

The backticks/single-quotes/whatever-you-wanna-call-them are used to be
explicit with a name.

-TG


----- Original Message -----
From: "Gary Wardell"
To:
Date: Thu, 13 Dec 2007 19:33:57 -0500
Subject: RE: [PHP-DB] UPDATE syntax

> Hi,
>
> I'm a beginner at PHP and MySql but a long time MS SQL server user.
>
> Maybe it should be `advertisements`.`displayed` instead?
>
> I just did a test and my Query browser doesn't like `interestcodes.id` but
> likes `interestcodes`.`id`. Notice the quotes
> (accents) on each side to the period.
>
> Gary

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php