We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,716 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

MySQL Query Problem

guys, can anyone help me on this problem? i have two tables then what I want is that, when an identical item is found in table2, it will not be displayed.

Example:

Table1                             Table2
item1                               other1
item2                               other2
item3                               item2
item4                               item3

Condition:
if we use this query: select * from Table1 the items from Table1 will appear but if the items of Table1 exists in Table2 then i must not be displayed.

how can i do that? thanks

3
Contributors
2
Replies
3 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
dashawk
Light Poster
39 posts since Jul 2011
Reputation Points: 17
Solved Threads: 3
Skill Endorsements: 0

select distinct
Or
use a union and make it distict.

Can you post your full query?

thines01
Postaholic
Team Colleague
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7

You can try

select name from Table2 where name not in (select * from Table1)
Reverend Jim
Carpe per diem
Moderator
3,592 posts since Aug 2010
Reputation Points: 561
Solved Threads: 445
Skill Endorsements: 32

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0591 seconds using 2.72MB