#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    Finland
    Posts
    716
    Rep Power
    51

    Wildcard in where clause


    I'm making a program with VB 6 and using ms access as database.
    I'm having a small problem with a query, so I was wondering if it's possible to have a wildcard in the where clause, like this

    "SELECT * FROM mytable WHERE mytable.* LIKE '" & keywords.TEXT & "'"

    I tried that one but it didn't work. I could of course separate all table columns and make their own LIKE-condition for each and every column, like this....

    "SELECT * FROM mytable WHERE product LIKE '" & keywords.TEXT & "' OR product_name LIKE '" & keywords.TEXT & "'.... etc


    ... but I'd rather find a way to use the wildcard thing.

    All ideas are welcome.

    Thank you in advance

    - Kimppa
    Fatal error on row 561: Couldn't access life - life isn't set
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,262
    Rep Power
    4279
    you cannot use a wildcard for the columns in a WHERE clause

    you need the LIKE condition on each column separately

    don't forget your wildcard character, which is * for Access

    also, please post Access questions into the Database Management forum next time, this is the SQL Server forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    Finland
    Posts
    716
    Rep Power
    51
    Thanks...
    And sorry for the wrong forum, didn't even notice it myself :-)
    Fatal error on row 561: Couldn't access life - life isn't set

IMN logo majestic logo threadwatch logo seochat tools logo