Code: Select all
INSERT user_referrals
SELECT $userId, $userId, 0
UNION
SELECT ancestor_id, $userId, depth+1 FROM user_referrals
WHERE descendant_id = $referralId
How do I check if a statement returned an empty result set or not? Is an empty result set just NULL or is it something else? How can I return something if the other thing is NULL, but if it isn't return the other thing (e.g. in javascript, var foo = foo || bar)?
Thanks for reading. All help is appreciated.