Jump to content

[SOLVED] Changing variable around before selecting


xOracle

Recommended Posts

MySQL client version: 4.1.22

I know the subject seems confusing, but I didn't know how else to put it. 

Basically what I want is to be able to modify the mySQL value for a certain column in the WHERE section before selecting.

 

The statement is as follows:

SELECT * FROM calendar WHERE date('j', eday)= '3' AND recurring='1'

eday is a timestamp in unix format (i.e: "1217566800") and I want to convert it into the day of the month before comparing it to the variable.

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' eday)='date('j'' date=' 1217566800)' AND recurring='1'' at line 1[/quote']

 

CREATE TABLE `events` (
  `id` int(255) NOT NULL auto_increment,
  `eday` int(15) NOT NULL default '0',
  `title` blob NOT NULL,
  `event` blob NOT NULL,
  `recurring` tinyint(1) NOT NULL default '0',
  `end_day` int(15) NOT NULL default '0',
  `startDate` int(10) NOT NULL default '0',
  `endDate` int(10) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;

 

Any help is appreciated, thanks.

 

what i'm trying to do is use PHP's date() function to convert the table value then compare THAT against the WHERE statement.

Don't do that...mysql has built-in date functions.

 

What's e-day? A timestamp?

This table is for a calendar.

 

eday is a timestamp of when the event occurs, but there is also an option for the user to choose that the event will occur on the same day of every month or every year, so what I want to do is select all the events that share the same day as the value in the WHERE part.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.