Help me with this msql query!

Thread Solved

Join Date: Apr 2009
Posts: 16
Reputation: chandradyani is an unknown quantity at this point 
Solved Threads: 0
chandradyani chandradyani is offline Offline
Newbie Poster

Help me with this msql query!

 
0
  #1
May 20th, 2009
I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

  1. $query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

It works on postgerSQL but not on mysql I dont why It couldn't work on mySQL

Please help me to revise this query
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: Help me with this msql query!

 
0
  #2
May 20th, 2009
  1. echo $query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'";

copy the output of echo statement and execute in mysql check whether query gives correct result or not.
if you got correct output then write..
  1. $sql=mysql_query($query);
Last edited by Aamit; May 20th, 2009 at 9:57 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 16
Reputation: chandradyani is an unknown quantity at this point 
Solved Threads: 0
chandradyani chandradyani is offline Offline
Newbie Poster

Re: Help me with this msql query!

 
0
  #3
May 20th, 2009
I have echo the query it seems well but it doesnt return a value. I dont know why it doesnt work on MySql
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: Help me with this msql query!

 
0
  #4
May 20th, 2009
post you code and table structure + value related to this ..
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 16
Reputation: chandradyani is an unknown quantity at this point 
Solved Threads: 0
chandradyani chandradyani is offline Offline
Newbie Poster

Re: Help me with this msql query!

 
0
  #5
May 20th, 2009
table structure is:
t_master_reg
--------------------------------------------------------
|field | type data |
--------------------------------------------------------
id_reg |VARCHAR
no_reg |VARCHAR
reg_subject | VARCHAR
dt_reg_stated | DATE
dt_reg_end | DATE
dt_reg_reminder | DATE

values ('1','regulation no 546','regulation subject','2009-05-05','2009-07-31','2009-06-31')

Here is my code
  1. $query = 'SELECT * FROM t_master_reg dt_reg_reminder >= '$today' AND dt_reg_end >='$today' ';

if I executed the query it will return an empty result. What should I do.Please help me..
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,419
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 229
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Help me with this msql query!

 
0
  #6
May 20th, 2009
What is $today equal to?
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 16
Reputation: chandradyani is an unknown quantity at this point 
Solved Threads: 0
chandradyani chandradyani is offline Offline
Newbie Poster

Re: Help me with this msql query!

 
0
  #7
May 20th, 2009
Originally Posted by ShawnCplus View Post
What is $today equal to?
$today= date("Y-m-d");
the result is $today=2009-05-21
Last edited by chandradyani; May 20th, 2009 at 3:45 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: shwetasm is an unknown quantity at this point 
Solved Threads: 1
shwetasm shwetasm is offline Offline
Newbie Poster

Re: Help me with this msql query!

 
0
  #8
May 20th, 2009
Originally Posted by chandradyani View Post
I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

  1. $query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

It works on postgerSQL but not on mysql I dont why It couldn't work on mySQL

Please help me to revise this query
Hi u can refer the following link, It might help u to solve ur problem.
http://www.w3schools.com/php/php_ref_date.asp
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 16
Reputation: chandradyani is an unknown quantity at this point 
Solved Threads: 0
chandradyani chandradyani is offline Offline
Newbie Poster

Re: Help me with this msql query!

 
0
  #9
May 20th, 2009
Originally Posted by shwetasm View Post
Hi u can refer the following link, It might help u to solve ur problem.
http://www.w3schools.com/php/php_ref_date.asp
Hi shwetasm,
thank fo the link but I haven't yet found the solution. It still not work on mySQL
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: jothika is an unknown quantity at this point 
Solved Threads: 1
jothika jothika is offline Offline
Newbie Poster

Re: please try this, and - letters is not using - using only simbol (&&)

 
0
  #10
May 21st, 2009
Originally Posted by chandradyani View Post
I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

  1. $query="select * from t_regulation where dt_reminder >= '$today' && dt_ended ='$today'"

It works on postgerSQL but not on mysql I dont why It couldn't work on mySQL

Please help me to revise this query
Re: please try this, and - letters is not using - using only simbol (&&)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC