$query="SELECT * FROM history WHERE  p_na LIKE '$p_na%' AND svreg LIKE '$svreg%' IN (SELECT  * FROM history WHERE cdate BETWEEN '2013-09-12' AND '2013-12-12')";
$sql=mysql_query("$query");

am searching for data LIKE a and LIKE b that falls between to dates.
I thought a sub query will be the best method, but its not working...

Member Avatar for diafol

I don't know why you're using a subquery. AFAIK, you'd need an alias for the subquery anyway.

"SELECT * FROM history WHERE  p_na LIKE '$p_na%' AND svreg LIKE '$svreg%' AND (cdate BETWEEN '2013-09-12' AND '2013-12-12)'

Perhaps even without the parentheses.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.