You are here: Re: How to use a value in table in query? « PHP SQL « IT news, forums, messages
Re: How to use a value in table in query?

Posted by Mick White on 10/08/54 11:27

Stefan Rybacki wrote:

> Mick White wrote:
>
>> mysql> select * from G;
>> +------------+-----------+----------------+--------+
>> | first_name | last_name | modified | offset |
>> +------------+-----------+----------------+--------+
>> | Mick | White | 20050923102539 | -5 |
>> +------------+-----------+----------------+--------+
>> 1 row in set (0.00 sec)
>>
>> mysql> select ADDDATE(modified,INTERVAL -5 HOUR) from G;
>> +------------------------------------+
>> | ADDDATE(modified,INTERVAL -5 HOUR) |
>> +------------------------------------+
>> | 2005-09-23 05:25:39 |
>> +------------------------------------+
>> 1 row in set (0.02 sec)
>>
>> How could I substitute `offset` value for -5 ?
>>
>> mysql> select ADDDATE(modified,INTERVAL,offset HOUR) from G;
>>
>> This produces an error (server version: 4.0.25-standard)
>> Mick
>>
>
> What is the error you get? Did you try to enclose offset in `?

I found the problem:
mysql> select ADDDATE(NOW(),INTERVAL offset HOUR) as minus_5 from G;
+---------------------+
| minus_5 |
+---------------------+
| 2005-09-23 15:19:41 |
+---------------------+
1 row in set (0.00 sec)

I had a comma after`INTERVAL`

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация