View previous topic :: View next topic
|
Author |
Message |
ramanatcs
New User
Joined: 23 Dec 2008 Posts: 7 Location: Bangalore
|
|
|
|
Hi All,
I want to retrieve the table names which contains the value as ‘Germany’ in different fileds of tables.
Suppose.
Table1
Column1 Column2 Column3 Column4 Column5
India
Germany
USA
Germany
Table3
Column1 Column2 Column3 Column4 Column5
Germany
Lonon
Germany
Japan
Table3
Column1 Column2 Column3 Column4 Column5
Australia
Lonon
Germany
Japan
-
-
-
-
-
upto 50 tables are there. I want to retrieve the table names out of 50 which contains 'Germany' as a column value.
Write a single SQL query. There is no key columns in all the tables.
Hope I am clear.
Thanks in advance |
|
Back to top |
|
|
abhishek dadhichi
New User
Joined: 19 Apr 2007 Posts: 37 Location: Bangalore
|
|
|
|
Hi ramanatcs,
Plz try the following query:
sel * from dbc.tables where column_name=germany
Thanks,
Abhishek |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Dick, can I vote for the answer? Since it doesn't meet the stated requirements, it can't really be considered an answer to the question. Although the question is lame, at least the person is wanting help. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you are right, Robert.
If I had edit authority on this board I would amend/delete my post. Done
as far as an answer to the OP's question, I don't know how to extract the table name and validate a table column's value for 50 tables in one SQL.
Code: |
Select 'table name one'
from table-name-one
where column = 'Germany'
UNION
Select 'table name two'
from table-name-two
where column = 'Germany'
...
UNION
Select 'table name 50'
from table-name-50
where column = 'Germany'
|
maybe someone else can provide an answer.
I apologize to ramanatcs and Abhishek. My previous post was needlessly rude and did not contribute to the thread. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Write a single SQL query. |
Why? Probably because "I want. . .". Maybe it is some homework assignment.
Given the complete lack of specification of what is really needed (it appears to be a list of every table that has the word "Germany" anywhere in the table?), one way might be to unload the tables and scan the unloaded output for the word "Germany". |
|
Back to top |
|
|
|