egalvan10
egalvan10

Reputation: 155

MySQL function pass a parameter from query

I have a function that will take a user's id as a parameter and do stuff using that parameter. I would like to call that function for several users.

For a single user I successfully use:

SELECT myFuncFoo(1);

And for multiple users I tried this without luck:

SELECT users.id as uid, 
(SELECT myFuncFoo(uid))
FROM users;

I also tried without aliases:

SELECT users.id,
(SELECT myFuncFoo(users.id))
FROM users;

How can I achieve this?

Upvotes: 1

Views: 2751

Answers (2)

sreenivas
sreenivas

Reputation: 21

select myFuncFoo(uid) from(select uid from users where uid=1);

Upvotes: 1

vhu
vhu

Reputation: 12798

Use the following if you want to execute myFuncFoo() for every row:

SELECT users.id,
myFuncFoo(users.id)
FROM users;

Upvotes: 5

Related Questions