Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: SELECT

Posted on 2011-10-17 19:38:22 by ron.piggott

------=_NextPart_000_0080_01CC8CD2.0A121600
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


I need help creating a mySQL query that will select the correct =
introduction message for a website I am making. The way I have designed =
the table I canâÂ=99t wrap my mind around the SELECT query that will =
deal with the day # of the month. =20

The part of the SELECT syntax I am struggling with is when the =
introduction message is to change mid month. The reason I am struggling =
with this is because I havenâÂ=99t used âÂ=98DATEâÂ=99 for =
the column type. The reason I didnâÂ=99t use âÂ=98DATEâÂ=99 =
is because the same message will be displayed year after year, depending =
on the date range. =20

What I am storing in the table is the start month # (1 to 12) and day # =
(1 to 31) and then the finishing month # (1 to 12) and the finishing day =
# (1 to 31)

Table structure for table `introduction_messages`
--

CREATE TABLE IF NOT EXISTS `introduction_messages` (
`reference` int(2) NOT NULL AUTO_INCREMENT,
`start_month` int(2) NOT NULL,
`start_day` int(2) NOT NULL,
`end_month` int(2) NOT NULL,
`end_day` int(2) NOT NULL,
`theme` varchar(100) NOT NULL,
`message` longtext NOT NULL,
PRIMARY KEY (`reference`)
) ENGINE=3DMyISAM DEFAULT CHARSET=3Dlatin1 AUTO_INCREMENT=3D8 ;

My query so far is:

SELECT * FROM `introduction_messages` WHERE 11 BETWEEN `start_month` AND =
`end_month`

11 is for November. 2 rows have been selected:

Row #1:
`start_month` 9
`start_day` 16
`end_month` 11
`end_day` 15

Row #2:
`start_month` 11
`start_day` 16
`end_month` 12
`end_day` 10

How do I modify the query to incorporate the day #?

Ron




www.TheVerseOfTheDay.info=20

------=_NextPart_000_0080_01CC8CD2.0A121600--

Report this message

#2: Re: SELECT

Posted on 2011-10-17 19:58:11 by Jim Giner

I would do it this way:

Where
$sel_d = (the day # you want)
$sel_m = (the month # you want)

The "where" clause would be:

Where (start_month => $sel_m and start_day => $sel_d) and
(end_month =< $sel_m and end_day =< $sel_d)

Someone else will probably have something more elegant, but I believe this
will work for you.

Never used the between clause before - have to remember that.



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

Report this message

#3: RE: Re: SELECT

Posted on 2011-10-17 20:20:24 by Toby Hart Dyke

Though the operators are >= and <=, not => and =<.

Toby

-----Original Message-----
From: Jim Giner [mailto:jim.giner@albanyhandball.com]
Sent: Monday, October 17, 2011 1:58 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Re: SELECT

I would do it this way:

Where
$sel_d = (the day # you want)
$sel_m = (the month # you want)

The "where" clause would be:

Where (start_month => $sel_m and start_day => $sel_d) and
(end_month =< $sel_m and end_day =< $sel_d)



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

Report this message

#4: Re: SELECT

Posted on 2011-10-18 03:16:37 by Amit Tandon

Report this message

#5: RE: SELECT

Posted on 2011-10-18 12:36:15 by M.Ford

Report this message

#6: Re: SELECT

Posted on 2011-10-18 16:31:20 by Jim Giner

Report this message