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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SaSystem1989
    New Member
    • Oct 2012
    • 2

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

    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.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Use where condition. For eg.
    Code:
    select * from HR_Master where position = 'CEO' and salary = 2354 and date = 'YYYY-MM-DD'
    Last edited by NeoPa; Nov 29 '12, 02:02 PM. Reason: Added [CODE] tags.

    Comment

    • SaSystem1989
      New Member
      • Oct 2012
      • 2

      #3
      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
      ......

      Comment

      • Meetee
        Recognized Expert Contributor
        • Dec 2006
        • 928

        #4
        Look up for information_sch ema which stores metadata information of database.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          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.

          Comment

          • coding master
            New Member
            • Nov 2012
            • 11

            #6
            use this conditon
            Code:
            Select * from HR_Table_Name where Designation='CEO' AND Salary='2354RS'AND date='MM-DD-YYYY'
            Last edited by NeoPa; Nov 29 '12, 02:01 PM. Reason: Trimmed wasted space.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32653

              #7
              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).

              Comment

              Working...