1

Is there any possibilty to add a function-call in a SQL-Query?

At the moment i'm doing this:

§sql = "SELECT * FROM TABLE";

But I want, that I'm using a field from my table and call with this a function, which return me true or false.

Maybe a example could explain it better:

"$sql = SELECT * FROM TABLE WHERE functionCall(TABLE.FIELD)=true";

Then I just get all entrys from TABLE, where my function returns true.

Is there any possibility to do that?

3
  • Read MySQL manuals for built-in functions. I think you can do your task with them Commented May 4, 2014 at 17:49
  • in addition: you can write stored functions, those will work too. But you can't refer to a php function ... Commented May 4, 2014 at 17:52
  • 1
    Can you explain what you would like the functionCall to do? Commented May 4, 2014 at 17:55

1 Answer 1

1

you could use If condition before like that :

 $sql = "SELECT * FROM TABLE";

 fetch your query here 

 If(functionCall($row['FIELD'])==true) {
    your wished code here
    .......
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.