By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,652 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,652 IT Pros & Developers. It's quick & easy.

How I can search data in database? search data including text, number and datetime

P: 2
hi all, is it possible to Search data in database? with a single sql script or some tools will help me?
for example ,I have a HR database ,and I want to search 'CEO', $2354.00 or '12/4/1996' in all of the records.
Oct 22 '12 #1

✓ answered by Rabbit

If you're looking for that value anywhere in any table in any row in any field in the database, you will have to return all the information schema data as meetee suggests. And then you will have to loop through it creating dynamic sql to do the actual search.

Just so you are aware, this is take tremendous amounts of time unless your database is small.

Share this Question
Share on Google+
6 Replies


Meetee
Expert Mod 100+
P: 931
Use where condition. For eg.
Expand|Select|Wrap|Line Numbers
  1. select * from HR_Master where position = 'CEO' and salary = 2354 and date = 'YYYY-MM-DD'
Oct 22 '12 #2

P: 2
what i mean is

search all columns of all tables ,search 2345 in the database ,returns table's names and column's names
for example:

owner tablename columnname
-------------------------------
HR salary monthly
HR salaryhis yearly
......
Oct 22 '12 #3

Meetee
Expert Mod 100+
P: 931
Look up for information_schema which stores metadata information of database.
Oct 22 '12 #4

Rabbit
Expert Mod 10K+
P: 12,430
If you're looking for that value anywhere in any table in any row in any field in the database, you will have to return all the information schema data as meetee suggests. And then you will have to loop through it creating dynamic sql to do the actual search.

Just so you are aware, this is take tremendous amounts of time unless your database is small.
Oct 22 '12 #5

P: 11
use this conditon
Expand|Select|Wrap|Line Numbers
  1. Select * from HR_Table_Name where Designation='CEO' AND Salary='2354RS'AND date='MM-DD-YYYY'
Nov 29 '12 #6

NeoPa
Expert Mod 15k+
P: 31,769
I'm afraid that wouldn't work for reasons already discussed in the thread (and others which haven't been - like it wouldn't match any records anyway).
Nov 29 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.