|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
MySQL where wildcard
I am running a select query as follows:
The $cat variable will hold a user selected category. The problem I have is if no category has been selected what can I use as a wild card such as * to select all the records? This MUST be loaded to the $cat variable and not be a change in the SQL statement. Any help much appreciated. |
|
#2
|
||||
|
||||
|
RE: MySQL where wildcard
There are two wildcard characters in MySQL: _ and %
_ (underscore) takes the places of exactly one character. % takes the places of 0 or more characters. (If you use wildcards, you need to use LIKE as the comparison operator instead of = ) So, category LIKE 'c?t' will match cat, cot, cut and category LIKE 'p%t' will match pt, pat, pet, pit, past, etc. |
|
#3
|
|||
|
|||
|
RE: MySQL where wildcard
|
|
#4
|
|||
|
|||
|
RE: MySQL where wildcard
Thanks for your help.
I am already using the option you have suggested Nazly. I was hoping for something bit tidier but it looks like it does not exist - maybe one day. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > MySQL where wildcard |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|