Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a simple table called unzip. It has three columns as follows -: id INT UNSIGNED NOT NULL AUTO_INCREMENT, share_src VARCHAR(30) NULL, creator INT UNSIGNED NOT NULL.

I also have a function called checkSrc which returns no or yes when a share_src is provided to it as a parameter.

I want to return all the rows where creator is 10 AND (share_src is null or the result from the function checkSrc is yes).

Currently i am doing this

SELECT * FROM unzip WHERE creator = 12 AND (share_src IS NULL || checkSrc(share_src) = 'yes');

But this results in an error. Whats the problem in the query? A lot thanks for help..

share|improve this question
 
What error you get –  AshReva Mar 20 at 20:54
 
What is parameter type function expecting? –  AshReva Mar 20 at 20:54
 
The parameter type is int –  Ray Z Mar 20 at 20:56
 
And what is col type for share_src? Also what is return type? What is error? –  AshReva Mar 20 at 20:57
 
Oh! Thanks @AshReva, i got it. Share_src is VARCHAR and the parameter expected is INT. Thanks a lot –  Ray Z Mar 20 at 20:58
show 1 more comment

1 Answer

up vote 0 down vote accepted

SELECT * FROM unzip WHERE creator = 12 AND (share_src IS NULL Or checkSrc(share_src) = 'yes');

Try and let me know.

Check if function is returning correct data type. Check if its returning string type.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.