Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

Sybase searches when you know part of the data

Tech Computer Center logo

A wildcard search is what you want when you know some of the data you are looking for and you know which column and table it is in. A wildcard is a character that matches any character, or any string of characters.

At the end of each command press the space-bar or press enter before continuing the next step.

  1. To do a wildcard search, type
            select
  2. Type the name of the columns you displayed after the search. Separate each column name with a comma.
    For instance, if you are searching for John Jones and you want to know his phone number and his address, so you would type
            phone, address
  3. If you want every column to be returned, type an asterisk.
  4. Type
            from
  5. Type the name of the table you are searching.
  6. Type
            where
  7. Type the name of the column you are searching.
  8. Type
            like
  9. Type
            "
  10. Type the information you know, mixed with wildcards. A wildcard is a character that matches any character, or any string of characters. In Sybase, the wildcard to match an single character is _ and the wildcard character that will match one or more characters is %. So, if you are looking for John, but you cant remember his name, you would use
            John%
    If you are looking for John Johnson, whose last name might be spelled Johnsen, you would type
            John Johns_n
    Wildcard characters can return all kinds of unsuspected results. John% would also return Johnathan, Johnnsonn, and Johnhilda James.
  11. Type
            "
  12. Type
            go
  13. Press Enter.

If there is a value that matches your search, you see the results from your search and

(1 row affected)

The number may be 2 or 3, or larger if your search matches more than one row.

For example, to find everyone whose name starts with John in a table called rolodex and return all the columns, type

        select * from rolodex where name like John%
        go

Next: Sybase searches for multiple columns
See also: Searching Sybase databases
Previous: Simple search in Sybase
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

Maintained by John Shipman, john@nmt.edu; original by Steve Anderson
Last updated: 1997/06/25 20:19:00 UT
URL: http://www.nmt.edu/tcc/help/db/sybase/wildcard_search.html
QR two-dimensional bar code