Link to home
Start Free TrialLog in
Avatar of dsrnu
dsrnu

asked on

Query Help - if(s.user_id <> NULL, 1, 0) not working as expected

I'm trying to make s.user_id return 1 if it's not null, otherwise return 0.. but my code below seems to be returning all zeroes.. any ideas?
'SELECT u.id AS user_id, u.username, if(s.user_id <> NULL, 1, 0) AS is_seller FROM ' . $this->user_table_name . ' u LEFT JOIN ' . $this->seller_table_name . ' s ON u.id=s.user_id'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rubene
rubene
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dsrnu
dsrnu

ASKER

you're awesome rubene! worked
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial