简体   繁体   中英

Select rows where column name not equals multiple values

I'm creating friend system,where users able to add as friend,accept friend request etc....

Table Structure

userfr_id(AUTO_INCREMENT)
user_id
friend_id
accepted(int 1)

Working functions

Friend request
Accept friend request
Display all friends..

Not Working functions

  • Delete friends
  • Cancel Friend request
  • check friend exits

Now i'm try to delete users as follow method

  • check user id and friend_id available row
  • get auto increment
  • use auto increment to run delete query

But my problem is any method available to check user id and friend_id available row ??

sample date in table row

http://i.imgur.com/xqZP9oF.png

i couldn't use where in because filed name are different

Any help

Mayby just try with:

SELECT *
  FROM table
 WHERE ( ( user_id = 4 AND friend_id = 5 ) OR
         ( user_id = 5 AND friend_id = 4 ) )              
   AND accepted = 1

If it returns one row, there is friendship, otherwise, they are not friends.

SELECT * FROM table_name WHERE !(ISNULL([columnname]));

TRy this place your query and additional condition

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM