473,226 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

IF and OR in a query

Having a little trouble returning the result I'm looking for in a
query and thought I'd ask a question here.

I have an input screen with a pull down menu to capture vacation
activity within a given month as well as capture overlap onto another
month. For example, if you're taking vacation between June 25 and
July 4, the input would be 'junjul' if the days off were July 4
through 10, the input would be 'jul' and if the days off happened to
be July 25 through August 5, the input would fall under 'julaug' with
the idea being that the query captures any vacation for the month of
July but also sends back info for any overlapping month vacation.
Also, if you did a query for the month of June or August, that
overlapping vacation would show as well. I did this very effectively
in Access once and am trying duplicate it with PHP.

So a question becomes, IF jul (is selected in the query for the month
of July) THEN return any data for junjul AND julaug if they were used
on the input form and have that data returned under a July query.

Any thoughts?
Jul 17 '05 #1
4 1448
On Sun, 05 Jun 2005 04:11:25 -0700, Chris wrote:
So a question becomes, IF jul (is selected in the query for the month
of July) THEN return any data for junjul AND julaug if they were used
on the input form and have that data returned under a July query.

Any thoughts?


Assuming you will sensibly have 2 date fields in your table:

$month = 7; // July
$sql = "SELECT id FROM planning WHERE MONTH(startdate)=$month OR
MONTH(enddate)=$month";
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #2
Another way of 'saying' that might be

IF jul THEN INCLUDE junjul AND julaug
(in the resultant query)

On Sun, 05 Jun 2005 04:11:25 -0700, Chris <coverland914 @ yahoo.com>
wrote:
Having a little trouble returning the result I'm looking for in a
query and thought I'd ask a question here.

I have an input screen with a pull down menu to capture vacation
activity within a given month as well as capture overlap onto another
month. For example, if you're taking vacation between June 25 and
July 4, the input would be 'junjul' if the days off were July 4
through 10, the input would be 'jul' and if the days off happened to
be July 25 through August 5, the input would fall under 'julaug' with
the idea being that the query captures any vacation for the month of
July but also sends back info for any overlapping month vacation.
Also, if you did a query for the month of June or August, that
overlapping vacation would show as well. I did this very effectively
in Access once and am trying duplicate it with PHP.

So a question becomes, IF jul (is selected in the query for the month
of July) THEN return any data for junjul AND julaug if they were used
on the input form and have that data returned under a July query.

Any thoughts?


Jul 17 '05 #3
(Response limited to comp.lang.php)

Chris wrote:
Having a little trouble returning the result I'm looking for in a
query and thought I'd ask a question here.

I have an input screen with a pull down menu to capture vacation
activity within a given month as well as capture overlap onto another
month. For example, if you're taking vacation between June 25 and
July 4, the input would be 'junjul' if the days off were July 4
through 10, the input would be 'jul' and if the days off happened to
be July 25 through August 5, the input would fall under 'julaug' with
the idea being that the query captures any vacation for the month of
July but also sends back info for any overlapping month vacation.
Also, if you did a query for the month of June or August, that
overlapping vacation would show as well. I did this very effectively
in Access once and am trying duplicate it with PHP.

So a question becomes, IF jul (is selected in the query for the month
of July) THEN return any data for junjul AND julaug if they were used
on the input form and have that data returned under a July query.

Any thoughts?


I think using the junjul/julaug/whatever will complicate matters. For
instance 0 my wife's ex-AA just had a baby and is taking 3 months off.
And my wife has > 2 months of vacation signed up. If you use
junjul/julaug, what about the person who takes an extended vacation such
as May 31 - August 2? Or even May 30 - Sept. 1?

To resolve everything, use a separate start date and end data, Then,
you need these tests:

1. start date >= 07/01 and start data <= 07/31 (or < 08/01 which
might be easier), or
2. end data - same as above, or
3. start date < 07/01 and end date > 07/31 (or >= 08/01)

Easily handled in SQL statements or date functions.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #4
Hello Chris,

Use: INSTR(columnname,'jul') > 0

This will evaluate to a positive integer when 'jul' is in the search column
or zero when it is not found.

Joseph Melnick
JM Web Consultants
http://www.jphp.com



"Chris" <coverland914 @ yahoo.com> wrote in message
news:lo********************************@4ax.com...
Another way of 'saying' that might be

IF jul THEN INCLUDE junjul AND julaug
(in the resultant query)

On Sun, 05 Jun 2005 04:11:25 -0700, Chris <coverland914 @ yahoo.com>
wrote:
Having a little trouble returning the result I'm looking for in a
query and thought I'd ask a question here.

I have an input screen with a pull down menu to capture vacation
activity within a given month as well as capture overlap onto another
month. For example, if you're taking vacation between June 25 and
July 4, the input would be 'junjul' if the days off were July 4
through 10, the input would be 'jul' and if the days off happened to
be July 25 through August 5, the input would fall under 'julaug' with
the idea being that the query captures any vacation for the month of
July but also sends back info for any overlapping month vacation.
Also, if you did a query for the month of June or August, that
overlapping vacation would show as well. I did this very effectively
in Access once and am trying duplicate it with PHP.

So a question becomes, IF jul (is selected in the query for the month
of July) THEN return any data for junjul AND julaug if they were used
on the input form and have that data returned under a July query.

Any thoughts?

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
14
by: Dave Thomas | last post by:
If I have a table set up like this: Name | VARCHAR Email | VARCHAR Age | TINYINT | NULL (Default: NULL) And I want the user to enter his or her name, email, and age - but AGE is optional. ...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.