LIKE operator and percent mark (%) syntax in comparison queries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vlad

    LIKE operator and percent mark (%) syntax in comparison queries

    I operate with 2 tables: tbLocations and tbDepartments. Both have a column
    named Town.

    tbLocations.Tow n looks like long unique list of different towns world wide:

    Copenhagen

    Madrid

    Roma

    Oslo

    Kiev

    Toronto

    Stockholm

    Moscow

    so on



    tbDepartments.T own looks like this:

    Madrid Kiev

    Roma Madrid Oslo

    Madrid

    Kiev



    I need to create a query, which uniquely extracts Towns from
    tbLocations.Tow n or from tbDepartments.T own that only exist in
    tbDepartments.T own. Something like this:

    Madrid

    Kiev

    Roma

    Oslo



    I have composed a query which partially solves problem:

    "SELECT tbLocations.Tow n FROM tbLocations, tbDepartments WHERE
    (tbLocations.To wn LIKE tbDepartments.T own)"

    Unfortunately it extracts only single word records, like this:

    Madrid

    Kiev



    Despite my attempts to use some combinations of wildcards, percent mark (%)
    and variations of upper commas after LIKE operator I couldn't get satisfied
    results.



    Platform: ASP; DB engine: MySQL



    Any help will be greatly appreciated

    Regards / Vlad


Working...