php - search multi keywords from sql -


so i'm getting data sql :

$date = 1-02-2011 $sql = "select * abc  date='$date'" 

now want data multiple dates creating graph

$date1 = 1-02-2011 $date2 = 2-02-2011 $date3 = 3-02-2011 $date4 = 4-02-2011 $date5 = 5-02-2011 $date6 = 6-02-2011 

and on..

is there quick way? or have create different querys each date?

you can use in:

select * abc date in ('2011-02-01', '2011-02-03', '2011-02-05') 

or if dates consecutive in example use between:

select * abc date between '2011-02-01' , '2011-02-06' 

then read results:

$result = mysql_query($query) or trigger_error(mysql_error());  while ($row = mysql_fetch_assoc($result)) {     $date =  $row['date'];     $col1 = $row['col1'];     // results. } 

edit: show null missing values can use left join:

select t1.date, t2.* (     select '2011-02-01' date     union     select '2011-02-02'     union     ...     union     select '2011-02-06' ) t1 left join t2 on t1.date = t2.date 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -