April 8, 2008 at 3:25 pm
I have a table with all the field names and tables in my database:
FIELD_NAME, TABLE_NAME
Some of the tables are LUTs, and they have the same field name present in them as the table they tie to.
I kind of want to do the OPPOSITE of "Distinct", in as much as I want all of the duplicate field names so I can see only the Table with it's companion LUT. Is there a way to do "Not Distinct" as a selection criteria?
As an example, in the attached graphic, the records highlighted in yellow are the ones I want, the ones in red ALMOST fit the criteria but I don't want them, nor do I want the non-highlighted records.
Thanks in advance...
Brad
April 8, 2008 at 3:51 pm
This won't handle the RED records, but it will get you close. 😀
SELECT FIELD_NAME, TABLE_NAME
FROM yourTable
WHERE FIELD_NAME IN (SELECT FIELD_NAME
FROM yourTable
GROUP BY FIELD_NAME
HAVING COUNT(*) > 1)
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgApril 8, 2008 at 4:13 pm
Thanks, Joel - that does get me a little closer. I guess I need to figure out how to filter out the tables that don't connect directly to the LUT.
Brad
April 9, 2008 at 7:11 am
Heh... nice job there "Joel" 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
April 9, 2008 at 8:16 pm
If you know that TABLE_NAME is fixed across any given FIELD_NAME, you can simplfy Joel's query like so:
SELECT FIELD_NAME, MIN(TABLE_NAME)
FROM yourTable
GROUP BY FIELD_NAME
HAVING COUNT(*) > 1)
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 10, 2008 at 6:36 am
Jeff Moden (4/9/2008)
Heh... nice job there "Joel" 😛
Hey, who the heck is this Joel guy? :hehe:
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgApril 10, 2008 at 9:26 am
Joel...Jason...to-MAY-toe...to-MAH-toe...whatever works! 😉
Thanks for the replies guys...and Joel, whereever you are...!
April 10, 2008 at 9:38 am
LOL, I've been called worse.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgApril 10, 2008 at 10:51 pm
Jason Selburg (4/10/2008)
Jeff Moden (4/9/2008)
Heh... nice job there "Joel" 😛Hey, who the heck is this Joel guy? :hehe:
I hope that you're not trying to take credit for Joel's fine work in this forum, sir. He won't be happy to hear that.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply