View Full Version : Query for wildcard


Exoduslow
03-04-2010, 09:57 AM
Hello I have recently started to use access and have came into some difficulty with one query in particular.

I am trying to create a query where the user can type in part of a product name and then be shown all of the matches.

So far this is what i have in the critera box

[Enter Product name: ]

I ahve tried the Wildcard * in as many places as I could think of and none would give the required result.

Sorry if my message is not very clear I am pretty new to access. If you need any more information please ask.

Thanks !

ajetrumpet
03-04-2010, 10:20 AM
I am trying to create a query where the user can type in part of a product name and then be shown all of the matches.

So far this is what i have in the critera box

[Enter Product name: ]
!

i wrote a faq for this. search forum for thread titled "using wildcards in queries".

also, the syntax you probably want to get it done is:WHERE [product field] =

"*" & [enter product name: ] & "*"

pbaldy
03-04-2010, 10:28 AM
WHERE [product field] =

"*" & [enter product name: ] & "*"

Except that you'd want to use Like rather than =.

ajetrumpet
03-04-2010, 01:40 PM
Except that you'd want to use Like rather than =.

laughing... :rolleyes:

vbaInet
03-04-2010, 01:49 PM
laughing... :rolleyes:
Was that a sarcastic laugh ajetrumpet? I am yet to see one of those ;)

ajetrumpet
03-04-2010, 02:22 PM
Was that a sarcastic laugh ajetrumpet? I am yet to see one of those ;)

the name is adam. okie dokie? :)

and no...it's sort of a "why do I have to be perfect all the time?" laugh. shouldn't the OP be able to assume that I meant to write "LIKE" instead of "="!?!? :D

I could've told him to try this query instead:$sql = "SELECT whatever

FROM table

WHERE productfield LIKE '%parameter%'";

mysql_query($sql);;) ;) I'm sure by now, this guy is thinking we're half crazy

vbaInet
03-04-2010, 02:40 PM
the name is adam. okie dokie? :)Comprend é :)


and no...it's sort of a "why do I have to be perfect all the time?" laugh. shouldn't the OP be able to assume that I meant to write "LIKE" instead of "="!?!? :D

I could've told him to try this query instead:$sql = "SELECT whatever

FROM table

WHERE productfield LIKE '%parameter%'";

mysql_query($sql);;)Keeping up the high standards the forum demands Adam. Shoot for the stars haha!!:D

;) ;) I'm sure by now, this guy is thinking we're half crazy :)He will think, "what a lovely thread I created"

I always wonder why your tags are always in PHP:confused:

pbaldy
03-04-2010, 02:52 PM
shouldn't the OP be able to assume that I meant to write "LIKE" instead of "="!?!?

Depends on the OP. Given that this one just joined and has 2 posts, there's a strong possibility they don't know about Like.

ajetrumpet
03-04-2010, 07:18 PM
they don't know about Like.

yeah but do they know about the healthcare summit? :D:D

Exoduslow
03-05-2010, 03:16 AM
i wrote a faq for this. search forum for thread titled "using wildcards in queries".

also, the syntax you probably want to get it done is:WHERE [product field] =

"*" & [enter product name: ] & "*"

Haha lol, no you guys are right I really don't have a clue about access. Just starting of this week really. Thanks for the help so far guys. I tried to type this into the criteria box, am I right in doing that?

Hopefully this example will help a bit. I have a product name of say "Hampton Lamp Table" there are also "Hampton Coffee Table" and other pieces in that range. I also will have other ranges such as Aspen in my Table. I would like a query so that if I type in Hampton then all pieces of Hampton will come up regardless of their full name. The queries that I am building so far only seem to be able to bring up the product when the full name is typed in.

Thanks very much for the help so far!

vbaInet
03-05-2010, 04:21 AM
This is what was suggested to be put in the Criteria box:

Like '*" & [Enter Product name: ] & "*'

Exoduslow
03-06-2010, 12:05 PM
Thanks very much guys you have been Great!

vbaInet
03-06-2010, 12:07 PM
Glad it worked for you. I hope you were also entertained too! :)

Exoduslow
03-06-2010, 02:00 PM
Haha yes, this seems like a pretty good forum!

vbaInet
03-06-2010, 02:04 PM
It sure is Exoduslow. Just stop by anytime and post a thread if you get stuck on matters covered on this Forum.

Have fun developing your db.

Exoduslow
03-06-2010, 02:06 PM
Thanks very much mate, I am actually working on it at the moment. :)