mysql - My SQL query showing error : : #1242 - Subquery returns more than 1 row -



mysql - My SQL query showing error : : #1242 - Subquery returns more than 1 row -

i have problem regarding mysql.

i have few tables tbl_follow, tbl_user, tbl_post_like,

now want query should homecoming result like:

i want userid, username, user image, user state 1 table->tbl_user, want users next other friend(other user) if column "estatus" in table "tbl_follow" contain value "active" otherwise if there "inactive" value should homecoming 0 have coded in query.

tbl_follow : 1.ifollowid, 2.iuserid, 3. ifriendid, 4. estatus

tbl_post_like: 1. ipostlikeid, 2. iuserid, 3. ipostid

tbl_user: 1.iuserid, 2. vusername, 3. vimage, 4. vstate

now simple query using is:

select u.iuserid, u.vusername, u.vstate, u.vimage, (select if( (select ifollowid tbl_follow iuserid =249 , ifriendid = 250 , estatus = 'active')!='', 1,0) tbl_follow) is_follow tbl_user u inner bring together tbl_post_like l on u.iuserid=l.iuserid l.ipostid=21

not sure performance on in comparing using additional join, it'll work:

try:

select u.iuserid, u.vusername, u.vstate, u.vimage, if(exists (select ifollowid tbl_follow iuserid =249 , ifriendid = 250 , estatus = 'active'), 1,0) is_follow tbl_user u inner bring together tbl_post_like l on u.iuserid=l.iuserid l.ipostid=21

mysql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -