SQL - fetch records based on a condition of two columns -


i need fetch records order no = abc has more 1 tracking number in large table can that?

i'll assume you're fetching records orders , "large table" trackingnumbers. can group by orderno in sub-query , refine sub-query using having clause. sub-query return ordernos in table more once. example:

select orderno   orders  orderno in (select orderno                      trackingnumbers                     group orderno                    having count(*) > 1) 

to identify duplicates in single table (as mentioned in comments):

select *   orders  group trackingnumber having count(*) > 1 

Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -