mysql - JOIN on keys that don't have the same value -
i trying inner join on 2 tables have similar values, not quite same. 1 table has qualified host name primary key, , other hosts short name, subdomain. it safe assume short name , subdomain unique.
so i've tried:
select table1.nisinfo.* table1.nisinfo inner join table2.hosts on (table1.nisinfo.shortname + '.' + table1.nisinfo.subdomainname + '.domain.com') = table2.hosts.fqhn table2.hosts.package = 'somepkg';
this doesn't return results expect, returns first result hundreds of times. i'd return distinct rows. takes long time run well.
what doing wrong? thinking of running subquery hostnames, don't know right path here is.
thank you!
you can use group in query can achieve desired results want please see 2 links
group 2 distinct columns in sql server
http://www.sqlteam.com/article/how-to-use-group-by-with-distinct-aggregates-and-derived-tables
Comments
Post a Comment