tsql - Join on tables with OR (repeating data) - SQL Server 2005 -
firstly put things context trying write search on sql server 2005. below table structure
schema1.table1 guid 1 2 3 schema2.table2 guid maintitle 1 water monkies 2 water doggies schema3.table3 guid maintitle 3 water hyrdas expected behavior user search 'water' , have retrieve guid in schema1.table1 match them entries in schema2.table2 , schema3.table3 guid in list , maintitle '%water%'
i have achieve using joins.
what i've done far is:
select schema1.table1.guid schema1.table1 join schema2.table2 on schema1.table1.guid = schema2.table2.guid join schema3.table3 on schema1.table1.guid = schema3.table3.guid but returns and'ed result gives me no results
i tried
select distinct schema1.table1.guid schema1.table1, schema2.table2, schema3.table3 (schema2.table2.guid=schema1.table1.guid or schema3.table3.guid=schema1.table1.guid ) , (schema2.table2.maintitle '%water%' or schema3.table3.maintitle '%water%') but since implied join returns rows of table2 table3s' maintitle water too.
can haz plese?
it's not possible joins, have use unions. although can't provide proof of this
select t1.guid t1 join (t2 union t3) t on t1.guid=t.guid t.maintitle '%water%' maybe
Comments
Post a Comment