vj5 Posted March 27, 2008 Share Posted March 27, 2008 Can someone please check my sql statement and tell what is wrong: $sql = 'SELECT UCASE(ph.groupno) as groupno, ph.name, ph.asof, p.managing_broker_id, ph.base, ph.current, ph.`gro/decline` FROM database1`. Policies p INNER JOIN `database2`.persHorizon ph ON p.GroupNumber = ph.groupno INNER JOIN dbBkrPol.Brokers b ON p.managing_broker_id = b.PersonID where 1';if (strlen($groupno)!=0) {$sql = $sql." AND `groupno` LIKE '%".$groupno."%'";}if (strlen($groupname)!=0) {$sql = $sql." AND `name` LIKE '%".$groupname."%'";}if (strlen($asofstart)!=0) {$sql = $sql." AND `asof` LIKE '%".$asofstart."%'";}if (strlen($asofend)!=0) {$sql = $sql." AND `asof` LIKE '%".$asofend."%'";}$sql = $sql." GROUP BY `asof` DESC"; Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2008 Share Posted March 27, 2008 FROM database1`. Policies p Link to comment Share on other sites More sharing options...
vj5 Posted March 27, 2008 Author Share Posted March 27, 2008 FROM database1`. Policies pThank you I corrected. Now I am getting the result set. I echoed the sql and posted in the database, it works there but it isn't working the web page I am working.echoed sql:SELECT UCASE(ph.groupno) as groupno, ph.name, ph.asof, p.managing_broker_id, ph.base, ph.current, ph.`gro/decline` FROM `database1`.Policies p INNER JOIN `database2`.persHorizon ph ON p.GroupNumber = ph.groupno INNER JOIN Brokers b ON p.managing_broker_id = b.PersonID where 1 GROUP BY `asof` DESC Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2008 Share Posted March 27, 2008 There's no difference between running a query on the database or through PHP, it will do the same thing. Link to comment Share on other sites More sharing options...
vj5 Posted March 27, 2008 Author Share Posted March 27, 2008 There's no difference between running a query on the database or through PHP, it will do the same thing.Why I am not getting this part when I am echoeing?if (strlen($groupno)!=0) {$sql = $sql." AND `groupno` LIKE '%".$groupno."%'";}if (strlen($groupname)!=0) {$sql = $sql." AND `name` LIKE '%".$groupname."%'";}if (strlen($asofstart)!=0) {$sql = $sql." AND `asof` LIKE '%".$asofstart."%'";}if (strlen($asofend)!=0) {$sql = $sql." AND `asof` LIKE '%".$asofend."%'";}I am searching on groupno, groupname, etc Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2008 Share Posted March 27, 2008 Because the if statements are evaluating to false. The string lengths are all 0. Link to comment Share on other sites More sharing options...
vj5 Posted March 27, 2008 Author Share Posted March 27, 2008 Because the if statements are evaluating to false. The string lengths are all 0.Yes, I am checking on the $CNT, it gives 0. What should I do? Link to comment Share on other sites More sharing options...
vj5 Posted March 27, 2008 Author Share Posted March 27, 2008 Below is the echoed sql query: SELECT UCASE(ph.groupno) as groupno, ph.name, ph.asof, p.managing_broker_id, ph.base, ph.current, ph.`gro/decline` FROM `dbBkrPol`.Policies p INNER JOIN `dbBkrPol`.persHorizon ph ON p.GroupNumber = ph.groupno INNER JOIN dbBkrPol.Brokers b ON p.managing_broker_id = b.PersonID where 1 AND `groupno` LIKE '%0095A%' AND `name` LIKE '%virtual%' GROUP BY `asof` DESC Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2008 Share Posted March 27, 2008 Yes, I am checking on the $CNT, it gives 0. What should I do?I don't know. What's the problem? The code seems to be working correctly. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.