MYSQL insert after sub query with count -
MYSQL insert after sub query with count -
i'm trying insert info table when subquery count > 0.
this have far.
insert users_friends (userid, friendid) values (77, 100) (select count(id) users email = 'a@g.com') > 0
both queries work independently fyi.
this should simple prepare hopefully. cheers
sqlfiddle demo if there records 'a@g.com'
sqlfiddle demo if there not records 'a@g.com'
insert users_friends (userid, friendid) select 77, 100 users email = 'a@g.com' limit 1;
another way be:
insert users_friends (userid, friendid) select 77, 100 dual exists ( select * users email = 'a@g.com' ) ;
mysql insert subquery nested-queries
Comments
Post a Comment