Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use SQL function

Status
Not open for further replies.

jianbo

Programmer
Dec 19, 2001
78
0
0
US
I am using MS SQL server2000.
I create a SQL function in database, let's call it func1.
Then I create a query statement like:
$query = "select * from table A where col1=func1(0)";
I am trying to use mssql_query($query) to run it, but it doesn't work.
How can I handle this?
 
have you made your connection call to the database?
eg.
Code:
$Connection = mysql_connect("localhost","username","password");
mysql_select_db ("database_name");
 
Yes, I do. bam720.
I can do all normal queries and stored procedures, but I don't know how to use functions in PHP.
Thanks,
 
i apologize i didn't quite see what you were trying to do.
The easiest way I can think of is to make sure you have a return statement in your function and then you set a varible before your sql statement to that varible. eg..
Code:
$myvalue = func1(0);
$query = "select * from table A where col1=$myvalue";

-------

function func1($Input){
//take input and operate on it
$output = $input + 1;
return $output;
}

Again I apoligze for the confusion. I misread your original post. I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top