954,116 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Now it throughing this error..

Unknown column 'id_tariffplan' in 'where clause'


That is a basic mysql error which means mysql has been told to search for a column named id_tariffplan however no such column exists. A common problem for this is mis-spelling the column and not having the column inserted in the first place.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Now it throughing this error..

Unknown column 'id_tariffplan' in 'where clause'


are you passing that variable at the time of calling.
Post it here, how you calling the procedure from php

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

id_tariffplan is the variable to hold the first parameter value passed to the stored procedure.
So its not a column name.Either the error is "unknown column idtariffplan" , (where idtariffplan is the column name) and id_tariffplan will just assign its value to it in the where clause.

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 
DROP PROCEDURE IF EXISTS `dd`.`view_ratecard`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `view_ratecard`(id_tariffplan int(11),page_size int(2),row_start int(2),country_code char(30))
BEGIN
SET @lim = CONCAT(' LIMIT ', row_start, ',', page_size);

if(country_code="") then
	SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from
	cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' ORDER by destination asc";
else
	SET @q = "select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from
	cc_ratecard where idtariffplan=id_tariffplan and rate_version='0' and dialprefix like concat(country_code,'%') ORDER by destination asc";

end if ;

SET @q = CONCAT(@q, @lim);
PREPARE st FROM @q;
EXECUTE st;
DEALLOCATE PREPARE st;
    END$$
DELIMITER ;
end if ;


This is your Store procedure..

i m just calling in database by call function

call view_ratecard_php('1','10','0','')

and it throughing the error

sam023
Junior Poster
164 posts since Jun 2009
Reputation Points: 11
Solved Threads: 6
 
id_tariffplan is the variable to hold the first parameter value passed to the stored procedure. So its not a column name.Either the error is "unknown column idtariffplan" , (where idtariffplan is the column name) and id_tariffplan will just assign its value to it in the where clause.

Exactly...

id_tariffplan is variable and idtraiffplan is column name..!!! but still i m getting this error

Unknown column 'id_tariffplan' in 'where clause'


i think it is because here you are writing query in string format..!! by string format i mean query in double quotes""... then how can u pass variable in it..?

i think for passing variable in string we need '?'

i have already a SP for limit..! but i just to try your SP..!!

sam023
Junior Poster
164 posts since Jun 2009
Reputation Points: 11
Solved Threads: 6
 

No.MySQL throws this error , when we try to specify a column name not present in the table structure.
So make sure the table structure is fine

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 
No.MySQL throws this error , when we try to specify a column name not present in the table structure. So make sure the table structure is fine
select dialprefix,destination,rateinitial,initblock,billingblock,id_trunk,grace,idtariffplan,id from

cc_ratecard where idtariffplan=id_tariffplan

Thats what i m saying.. Mysql taking id_tariffplan as column not as variable.. and there is no column name as id_tariffplan...thats why it is throwing that error..!! may be because it in string format..!!!

even if u run above query out of SP(directly).. it will throw same error..!!!

sam023
Junior Poster
164 posts since Jun 2009
Reputation Points: 11
Solved Threads: 6
 

i hope now getting me..!

sam023
Junior Poster
164 posts since Jun 2009
Reputation Points: 11
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You