mysql - SQL query to only select row if specific condition is met -


consider following sql query:

select friends.name friendname, friends.surname friendsurname, friends.number friendnumber, friends.gender friendgender,  clients.name clientname, clients.surname clientsurname friends inner join clients on friends.clientid = clients.id datetime(friends.creationdate, 'localtime') >= datetime('some_test_time') , datetime(friends.creationdate, 'localtime') <= datetime('some_test_time') 

both friends , clients tables have number column want compare in query: if friends.number in clients' table (clients.number column) don't select particular row anymore. how possible accomplish in 1 query?

example:


table clients: -------------------------- id  name  surname number  1   john  smith   55555 2   sam   wesker  12345 3   adam  nye     48745 --------------------------  table friends:  ---------------------------------- id  name  surname number clientid  1   abcd  qwert   88888  2 2   dddd  asdfg   48745  2 3   ffff  zxcvb   77777  3 ---------------------------------- 

the query should omit second row in friends because number present in clients' table

add :

and friends.number not in (select clients.number clients) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -