i have this query but this shows column does not exist
SELECT
p.content,
(select count(*) from share_member WHERE username='pratik' AND share_id=share) as allow
FROM posts p WHERE allow >="1"
and i got this error
Unknown column ‘allow’ in ‘where clause’
EDIT:
This edit has been done to improve sql query for my use
SELECT
p.content,
CASE share_type
WHEN 'public' then "1"
when 'lsit' then
(select count(*) from share_member WHERE username='pratik' AND share_id=share)
end as allow
FROM posts p WHERE allow=>1
Error code 1064, SQL state 42000
You cannot use column aliases in
WHEREclause.You can, however, use
HAVINGclause instead, there you can use aliases. Difference being thatWHEREis performed while constructing resultset, andHAVINGis applied after the whole set is matched (which means in general, thatHAVINGis heavier).EDIT: Your second query should look like this: