finding duplicate fields

finding duplicate fields

am 09.06.2006 15:39:10 von Ike

This may be a particularly dumb question, but I'm wrestling with it anyways.
Is there a way, to discern a duplicate field among records in a table. For
example, suppose I have a table such that:

CREATE TABLE `sometable` (
`id` int(11) NOT NULL auto_increment,
`sometext` varchar(80) NOT NULL default '',
PRIMARY KEY (`id`)
)

I want to find all records where `sometext` = `sometext` in another
record. That is, I want to find those records where there is more than one
instance of `sometext` without regard to what `sometext` is. I may have a
row where `sometext` = "abc" and another where it is `zyx` and I do not
want to put a value for `sometext` into the WHERE portion of my sql select
statement. How can I find duplicated fields where I dont know what the value
of the field being duplicated is a priori? Thanks, Ike

Re: finding duplicate fields

am 19.05.2007 18:08:22 von VeloMaster

On Fri, 09 Jun 2006 13:39:10 GMT, "Ike" wrote:

Try this:
SELECT f.*, s.* FROM firsttable f, secondtable s WHERE f.somecolumn =
s.somecolumn

>This may be a particularly dumb question, but I'm wrestling with it anyways.
>Is there a way, to discern a duplicate field among records in a table. For
>example, suppose I have a table such that:
>
>CREATE TABLE `sometable` (
> `id` int(11) NOT NULL auto_increment,
> `sometext` varchar(80) NOT NULL default '',
> PRIMARY KEY (`id`)
>)
>
>I want to find all records where `sometext` = `sometext` in another
>record. That is, I want to find those records where there is more than one
>instance of `sometext` without regard to what `sometext` is. I may have a
>row where `sometext` = "abc" and another where it is `zyx` and I do not
>want to put a value for `sometext` into the WHERE portion of my sql select
>statement. How can I find duplicated fields where I dont know what the value
>of the field being duplicated is a priori? Thanks, Ike
>