View Single Post
  #5 (permalink)  
Old Jan 27th, 2008, 12:55
Rakuli's Avatar
Rakuli Rakuli is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Seraching inside all tables

I think he's asking for a way to get the table name containing the value rather than get the results themselves.

The query might look something like this

Code: Select all
SELECT t1.f4 AS table1, t2.f4 AS table2, t3.f4 AS table3, t4.f4 AS table4, t5.f4 AS table5  
FROM t1 
LEFT JOIN t2 ON (t1.f4=t2.f4) 
LEFT JOIN t3 ON (t2.f4-t3.f4)
LEFT JOIN t4 ON (t3.f4=t4.f4)
LEFT JOIN t5 ON (t4.f4=t5.f4) 
WHERE t1.f4 = 'felix' OR t2.f4 = 'felix' OR t3.f4 = 'felix OR t4.f4 = 'felix' OR t5.f4 = 'felix'
That query above will give alarge result set but basically the columns it returns will be named table1-5 respectively. It's then a matter of checking if any of the rows return have a value of felix under table-15
Reply With Quote