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

Help for mysql Join

Hello !!

I need help fot the following situation:

I have 2 tables: test1 and test2:
each one have the same columns name: data
test1:
column data

values (black, white)

test2:
column data
values(white,black,orange, yellow)

what sql sentence i can use to show only the values (orange, yellow) the difference between the 2 tables?

3
Contributors
3
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
4
Views
Question
Answered
jeyjey88
Newbie Poster
2 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Are you looking for this?

SELECT * FROM test1, test2 WHERE test1.data!=test2.data
mwasif
Posting Whiz
315 posts since Dec 2007
Reputation Points: 29
Solved Threads: 48
Skill Endorsements: 0

Try this

SELECT test1.data FROM test1 JOIN test2 ON test1.data!=test2.data
anand01
Posting Whiz in Training
288 posts since Aug 2010
Reputation Points: 12
Solved Threads: 22
Skill Endorsements: 0

Thanks to everyone for replying to my questions!

All seems to work fine.

but particulary i have tried this one:

SELECT DISTINCT test1.data
FROM test1.data
WHERE (test1.data) NOT IN
(SELECT test2.data FROM test2)

it´s a bit more flexible.

jeyjey88
Newbie Poster
2 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by mwasif and anand01

This question has already been solved: Start a new discussion instead

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