Q: get certain row from mysql table comparing with another table value I need some help in mysql query.
I have two tables, like below
table 1
ID NAME    ADDRESS
1  test    testing address
2  test1    testing address 
3  test2    testing address 

table 2
ID  user_id    date
1   2          123456789

 my query was
SELECT * FROM table1,table2 on table1.ID = table2.user_id where table2.date != 123456789 

but it won't work.
I need data from table1 without ID 2 like below output
ID name address
1  test1 testing address
3  test3 testing address


A: Check your syntax       
 SELECT * FROM table1 t1 
 INNER JOIN table2 t2 on t1.ID = t2.user_id where t2.date != '123456789'


A: Use a left join to get only records that don't exist in the second table
SELECT tabl1.* 
FROM table1
left join table2 on table1.ID = table2.user_id 
where table2.user_id is null

See this great explanation of joins

A: Try this:-
SELECT * FROM table1 t1 
inner join table2 t2 on t1.ID <> t2.user_id;

Hope it will help you.
