SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Feb 24, 2001, 19:16 #1
Here is the broken code:
1. $query = "SELECT * FROM entertainment"
2. . " WHERE ent_category = '$class'"
3. . " and start >= DATE_SUB('$Today', INTERVAL 15 DAY)"
4. . " and end >= '$Today'"
5. . " or duration == 'on_going'"
6. . " or duration == 'single_date'"
7. . " ORDER BY ent_category asc";
Here are the parts that work well togeather:
1. $query = "SELECT * FROM entertainment"
2. . " WHERE ent_category = '$class'"
3. . " and start >= DATE_SUB('$Today', INTERVAL 15 DAY)"
4. . " and end >= '$Today'"
7. . " ORDER BY ent_category asc";
Here is the goal: To pull all the data regardless of the status of one day show, multiple day show or on going listing.
This is code for an entertainment posting element of my page. I want to have three durations (some will be ongoing listings, some one day and some with a start and stop date).
Here is the problem:
I need to use the OR in the SELECT but am not sure just how to do it. Clarifying: If i do an OR is that for the immediately preceding AND or for all the preceeding ANDs?
Suggestions?
thanksEd Shuck
www.noevalley.com
-
Feb 24, 2001, 20:05 #2
- Join Date
- Jan 2001
- Location
- buried in the database shell (Washington, DC)
- Posts
- 1,107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
First off, you don't need to worry about breaking it over multiple lines -- PHP and MySQL do not care and it's easier to read (in my opinion) like this:
Code:$query = "SELECT * FROM entertainment WHERE ent_category = '$class' AND start >= DATE_SUB( '$Today', INTERVAL 15 DAY) AND end >= '$Today' OR duration == 'on_going' OR duration == 'single_date' ORDER BY ent_category asc";
Code:$query = "SELECT * FROM entertainment WHERE ent_category = '$class' AND ( start >= DATE_SUB( '$Today', INTERVAL 15 DAY) AND end >= '$Today' ) OR ( duration == 'on_going' OR duration == 'single_date' ) ORDER BY ent_category asc";
Matt - Sybase DBA / PHP fanatic
Sybase/MySQL/Oracle | I don't like MySQL
Download Sybase | DBForums.com - for all your RDBMS talk
-
Feb 25, 2001, 16:03 #3
thanks MattR
$query = "SELECT *
FROM entertainment
WHERE ent_category = '$class'
AND start >= DATE_SUB( '$Today', INTERVAL 15 DAY)
AND ( end >= '$Today'
OR duration == 'on_going'
OR duration == 'single_date' )
ORDER BY ent_category asc";
I have set up the (). I have some other problem also but I will work that,
Thank You for the help.
peace
Hi, I found the other proble, The query failed caused by the == .
Thanks
ed==Last edited by edshuck; Feb 25, 2001 at 16:30.
Ed Shuck
www.noevalley.com
-
Feb 25, 2001, 16:44 #4
- Join Date
- Jan 2001
- Location
- buried in the database shell (Washington, DC)
- Posts
- 1,107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No problem, yeah single = in SQL.
HOLY COW. What are these neat things above the post window?Matt - Sybase DBA / PHP fanatic
Sybase/MySQL/Oracle | I don't like MySQL
Download Sybase | DBForums.com - for all your RDBMS talk
Bookmarks