phani_kosaraju Posted September 26, 2009 Share Posted September 26, 2009 Hi All, I am generating one query dynamically in php, that query looks like this "SELECT sum(a.premium_amt), c.base_premium FROM policy_holders a, policy_status b, ins_plans c WHERE a.login_date <= '$lastDate' AND b.ph_id = a.ph_id AND b.issued_date <= '$issue' AND b.ph_status = 2 AND a.ro_id = '".$ro_id."' AND programecode = 4 AND a.policy_name = ".$policy_row['0']." AND c.plan_id = a.policy_name" when i am echoing the query it is showing that query, if i copy that query and run in phpmyadmin it is producing good and correct results. But if i run the same query by using mysql_query function it is giving null values. if you remove a.ro_id = '".$ro_id."' or programecode = 4 or b.ph_id = a.ph_id From that query then it is running perfectly in mysql_query function. But i need to have that condition. If you need any clarification regarding my problem ping me in gtalk at [email protected] Thanks in Advance. Link to comment https://forums.phpfreaks.com/topic/175575-help-need-regarding-mysql_query-function/ Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 So is the database incorrectly set up wrong, are you selecting NOT NULL when the tables where first created? Can be NULL or NOT NULL set only, switch try again? Dont see the problem, if mysql says it ok in phpmyadmin? look at your mysql join again, brake it down, and look hard, looks wrong to me? "SELECT sum(a.premium_amt), c.base_premium FROM policy_holders a, policy_status b, ins_plans c WHERE a.login_date <= '$lastDate' AND b.ph_id = a.ph_id AND b.issued_date <= '$issue' AND b.ph_status = 2 AND a.ro_id = '".$ro_id."' AND programecode = 4 AND a.policy_name = ".$policy_row['0']." AND c.plan_id = a.policy_name" how can a id match a name weird? c.plan_id = a.policy_name ((unless policy name is not a int(number Link to comment https://forums.phpfreaks.com/topic/175575-help-need-regarding-mysql_query-function/#findComment-925194 Share on other sites More sharing options...
phani_kosaraju Posted September 26, 2009 Author Share Posted September 26, 2009 Hi, Thanks for your reply, c.plan_id and a.policy_name both are int columns only. can i mail you the table structures of 3 tables? Thanks Link to comment https://forums.phpfreaks.com/topic/175575-help-need-regarding-mysql_query-function/#findComment-925263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.